public class HashBag<T> extends AbstractHashBag<T> implements Externalizable
Modifier and Type | Method and Description |
---|---|
static <E> HashBag<E> |
newBag() |
static <E> HashBag<E> |
newBag(Bag<? extends E> source) |
static <E> HashBag<E> |
newBag(int size) |
static <E> HashBag<E> |
newBag(Iterable<? extends E> source) |
static <E> HashBag<E> |
newBagWith(E... elements) |
MutableBag<T> |
newEmpty()
Creates a new empty mutable version of the same collection type.
|
void |
readExternal(ObjectInput in) |
MutableBag<T> |
selectByOccurrences(IntPredicate predicate)
Returns all elements of the bag that have a number of occurrences that satisfy the predicate.
|
HashBag<T> |
with(T... elements) |
HashBag<T> |
with(T element)
This method allows mutable and fixed size collections the ability to add elements to their existing elements.
|
HashBag<T> |
with(T element1,
T element2) |
HashBag<T> |
with(T element1,
T element2,
T element3) |
HashBag<T> |
withAll(Iterable<? extends T> iterable)
This method allows mutable and fixed size collections the ability to add multiple elements to their existing
elements.
|
HashBag<T> |
without(T element)
This method allows mutable and fixed size collections the ability to remove elements from their existing elements.
|
HashBag<T> |
withoutAll(Iterable<? extends T> iterable)
This method allows mutable and fixed size collections the ability to remove multiple elements from their existing
elements.
|
void |
writeExternal(ObjectOutput out) |
add, addAll, addOccurrences, clear, contains, each, equals, forEachWith, forEachWithIndex, forEachWithOccurrences, groupBy, groupByEach, hashCode, isEmpty, iterator, occurrencesOf, remove, removeAllIterable, removeIf, removeIfWith, removeOccurrences, setOccurrences, size, sizeDistinct, toMapOfItemToCount
asParallel, asSynchronized, asUnmodifiable, collect, collectBoolean, collectByte, collectChar, collectDouble, collectFloat, collectIf, collectInt, collectLong, collectShort, collectWith, flatCollect, partition, partitionWith, reject, rejectWith, select, selectInstancesOf, selectWith, tap, toImmutable, zip, zipWithIndex
addAllIterable, aggregateBy, aggregateInPlaceBy, allSatisfy, allSatisfyWith, anySatisfy, anySatisfyWith, bottomOccurrences, chunk, detect, detectIfNone, detectOptional, detectWith, detectWithIfNone, detectWithOptional, getFirst, getLast, groupByUniqueKey, max, max, maxBy, min, min, minBy, noneSatisfy, noneSatisfyWith, removeAll, retainAll, retainAllIterable, selectAndRejectWith, sumByDouble, sumByFloat, sumByInt, sumByLong, topOccurrences
collect, collectBoolean, collectByte, collectChar, collectDouble, collectFloat, collectIf, collectInt, collectLong, collectShort, collectWith, count, flatCollect, groupBy, groupByEach, injectInto, injectInto, injectInto, injectInto, injectInto, injectIntoWith, reject, rejectWith, select, selectWith, sumOfDouble, sumOfFloat, sumOfInt, sumOfLong, toBag, toList, toSet, toSortedBag, toSortedBag, toSortedList, toSortedSet, toSortedSet, toStringOfItemToCount
appendString, appendString, asLazy, containsAll, containsAllArguments, containsAllIterable, countWith, forEach, groupByUniqueKey, into, toArray, toArray, toMap, toSortedBagBy, toSortedListBy, toSortedMap, toSortedMap, toSortedSetBy, toString, zip, zipWithIndex
bottomOccurrences, topOccurrences
reduceInPlace, reduceInPlace, summarizeDouble, summarizeFloat, summarizeInt, summarizeLong, toStringOfItemToCount
addAllIterable, aggregateBy, aggregateInPlaceBy, groupByUniqueKey, injectIntoWith, retainAllIterable, selectAndRejectWith, sumByDouble, sumByFloat, sumByInt, sumByLong
containsAll, parallelStream, removeAll, removeIf, retainAll, spliterator, stream, toArray, toArray
allSatisfy, allSatisfyWith, anySatisfy, anySatisfyWith, appendString, appendString, appendString, asLazy, chunk, collect, collectBoolean, collectByte, collectChar, collectDouble, collectFloat, collectIf, collectInt, collectLong, collectShort, collectWith, containsAll, containsAllArguments, containsAllIterable, count, countWith, detect, detectIfNone, detectOptional, detectWith, detectWithIfNone, detectWithOptional, flatCollect, getFirst, getLast, getOnly, groupBy, groupByEach, groupByUniqueKey, injectInto, injectInto, injectInto, injectInto, injectInto, into, makeString, makeString, makeString, max, max, maxBy, min, min, minBy, noneSatisfy, noneSatisfyWith, notEmpty, reduce, reject, rejectWith, select, selectWith, sumOfDouble, sumOfFloat, sumOfInt, sumOfLong, toArray, toArray, toBag, toList, toMap, toSet, toSortedBag, toSortedBag, toSortedBagBy, toSortedList, toSortedList, toSortedListBy, toSortedMap, toSortedMap, toSortedSet, toSortedSet, toSortedSetBy, toString, zip, zipWithIndex
forEach
public static <E> HashBag<E> newBag()
public static <E> HashBag<E> newBag(int size)
public static <E> HashBag<E> newBagWith(E... elements)
public MutableBag<T> selectByOccurrences(IntPredicate predicate)
Bag
selectByOccurrences
in interface Bag<T>
selectByOccurrences
in interface MutableBag<T>
selectByOccurrences
in interface MutableBagIterable<T>
selectByOccurrences
in interface UnsortedBag<T>
selectByOccurrences
in class AbstractHashBag<T>
public void writeExternal(ObjectOutput out) throws IOException
writeExternal
in interface Externalizable
IOException
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
readExternal
in interface Externalizable
IOException
ClassNotFoundException
public HashBag<T> without(T element)
MutableCollection
MutableCollectionIn the case oflist; list = list.without("1"); list = list.without("2"); return list;
FixedSizeCollection
a new instance of MutableCollection will be returned by without, and
any variables that previously referenced the original collection will need to be redirected to reference the
new instance. For other MutableCollection types you will replace the reference to collection with the same
collection, since the instance will return "this" after calling remove on itself.without
in interface MutableBag<T>
without
in interface MutableBagIterable<T>
without
in interface MutableCollection<T>
Collection.remove(Object)
public MutableBag<T> newEmpty()
MutableCollection
newEmpty
in interface MutableBag<T>
newEmpty
in interface MutableCollection<T>
public HashBag<T> with(T element)
MutableCollection
MutableCollectionIn the case oflist; list = list.with("1"); list = list.with("2"); return list;
FixedSizeCollection
a new instance of MutableCollection will be returned by with, and any
variables that previously referenced the original collection will need to be redirected to reference the
new instance. For other MutableCollection types you will replace the reference to collection with the same
collection, since the instance will return "this" after calling add on itself.with
in interface MutableBag<T>
with
in interface MutableBagIterable<T>
with
in interface MutableCollection<T>
Collection.add(Object)
public HashBag<T> withAll(Iterable<? extends T> iterable)
MutableCollection
MutableCollectionIn the case oflist; list = list.withAll(FastList.newListWith("1", "2")); return list;
FixedSizeCollection
a new instance of MutableCollection will be returned by withAll, and
any variables that previously referenced the original collection will need to be redirected to reference the
new instance. For other MutableCollection types you will replace the reference to collection with the same
collection, since the instance will return "this" after calling addAll on itself.withAll
in interface MutableBag<T>
withAll
in interface MutableBagIterable<T>
withAll
in interface MutableCollection<T>
Collection.addAll(Collection)
public HashBag<T> withoutAll(Iterable<? extends T> iterable)
MutableCollection
MutableCollectionIn the case oflist; list = list.withoutAll(FastList.newListWith("1", "2")); return list;
FixedSizeCollection
a new instance of MutableCollection will be returned by withoutAll,
and any variables that previously referenced the original collection will need to be redirected to reference the
new instance. For other MutableCollection types you will replace the reference to collection with the same
collection, since the instance will return "this" after calling removeAll on itself.withoutAll
in interface MutableBag<T>
withoutAll
in interface MutableBagIterable<T>
withoutAll
in interface MutableCollection<T>
Collection.removeAll(Collection)
Copyright © 2004–2016. All rights reserved.