Class HashBagWithHashingStrategy<T>
- java.lang.Object
-
- org.eclipse.collections.impl.AbstractRichIterable<T>
-
- org.eclipse.collections.impl.bag.AbstractBag<T>
-
- org.eclipse.collections.impl.bag.mutable.AbstractMutableBagIterable<T>
-
- org.eclipse.collections.impl.bag.mutable.AbstractMutableBag<T>
-
- org.eclipse.collections.impl.bag.mutable.AbstractHashBag<T>
-
- org.eclipse.collections.impl.bag.strategy.mutable.HashBagWithHashingStrategy<T>
-
- All Implemented Interfaces:
java.io.Serializable
,java.lang.Iterable<T>
,java.util.Collection<T>
,Bag<T>
,MutableBag<T>
,MutableBagIterable<T>
,UnsortedBag<T>
,MutableCollection<T>
,InternalIterable<T>
,RichIterable<T>
public class HashBagWithHashingStrategy<T> extends AbstractHashBag<T> implements java.io.Serializable
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description private HashingStrategy<? super T>
hashingStrategy
private static long
serialVersionUID
-
Fields inherited from class org.eclipse.collections.impl.bag.mutable.AbstractHashBag
items, size
-
-
Constructor Summary
Constructors Modifier Constructor Description HashBagWithHashingStrategy(HashingStrategy<? super T> hashingStrategy)
HashBagWithHashingStrategy(HashingStrategy<? super T> hashingStrategy, int size)
private
HashBagWithHashingStrategy(HashingStrategy<? super T> hashingStrategy, MutableObjectIntMap<T> map)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected int
computeHashCode(T item)
HashingStrategy<? super T>
hashingStrategy()
static <E> HashBagWithHashingStrategy<E>
newBag(HashingStrategy<? super E> hashingStrategy)
static <E> HashBagWithHashingStrategy<E>
newBag(HashingStrategy<? super E> hashingStrategy, int size)
static <E> HashBagWithHashingStrategy<E>
newBag(HashingStrategy<? super E> hashingStrategy, java.lang.Iterable<? extends E> source)
static <E> HashBagWithHashingStrategy<E>
newBag(HashingStrategy<? super E> hashingStrategy, Bag<? extends E> source)
static <E> HashBagWithHashingStrategy<E>
newBagWith(HashingStrategy<? super E> hashingStrategy, E... elements)
MutableBag<T>
newEmpty()
Creates a new empty mutable version of the same collection type.MutableBag<T>
selectByOccurrences(IntPredicate predicate)
Returns all elements of the bag that have a number of occurrences that satisfy the predicate.MutableBag<T>
with(T element)
This method allows mutable and fixed size collections the ability to add elements to their existing elements.MutableBag<T>
withAll(java.lang.Iterable<? extends T> elements)
This method allows mutable and fixed size collections the ability to add multiple elements to their existing elements.MutableBag<T>
without(T element)
This method allows mutable and fixed size collections the ability to remove elements from their existing elements.MutableBag<T>
withoutAll(java.lang.Iterable<? extends T> elements)
This method allows mutable and fixed size collections the ability to remove multiple elements from their existing elements.protected java.lang.Object
writeReplace()
-
Methods inherited from class org.eclipse.collections.impl.bag.mutable.AbstractHashBag
add, addOccurrences, allSatisfyWithOccurrences, anySatisfyWithOccurrences, clear, contains, detectWithOccurrences, distinctView, each, equals, forEachWith, forEachWithIndex, forEachWithOccurrences, getKeysView, groupBy, groupByEach, hashCode, isEmpty, iterator, noneSatisfyWithOccurrences, occurrencesOf, remove, removeAllIterable, removeIf, removeIfWith, removeOccurrences, setOccurrences, size, sizeDistinct, toMapOfItemToCount
-
Methods inherited from class org.eclipse.collections.impl.bag.mutable.AbstractMutableBag
asParallel, asSynchronized, asUnmodifiable, collect, collectIf, collectWith, collectWithOccurrences, countBy, countByEach, countByWith, flatCollect, partition, partitionWith, reject, rejectWith, select, selectInstancesOf, selectWith, tap, toImmutable, zip, zipWithIndex
-
Methods inherited from class org.eclipse.collections.impl.bag.mutable.AbstractMutableBagIterable
addAll, addAllBag, addAllIterable, 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
-
Methods inherited from class org.eclipse.collections.impl.bag.AbstractBag
collect, collectBoolean, collectByte, collectChar, collectDouble, collectFloat, collectIf, collectInt, collectLong, collectShort, collectWith, count, flatCollect, flatCollectBoolean, flatCollectByte, flatCollectChar, flatCollectDouble, flatCollectFloat, flatCollectInt, flatCollectLong, flatCollectShort, groupBy, groupByEach, injectInto, injectInto, injectInto, injectInto, injectInto, injectIntoWith, occurrencesSortingBy, reject, rejectWith, select, selectWith, sumOfDouble, sumOfFloat, sumOfInt, sumOfLong, toBag, toList, toListWithOccurrences, toSet, toSortedBag, toSortedBag, toSortedList, toSortedSet, toSortedSet, toStringOfItemToCount
-
Methods inherited from class org.eclipse.collections.impl.AbstractRichIterable
appendString, appendString, asLazy, containsAll, containsAllArguments, containsAllIterable, countWith, forEach, groupByUniqueKey, into, toArray, toArray, toBiMap, toMap, toSortedBagBy, toSortedListBy, toSortedMap, toSortedMap, toSortedMapBy, toSortedSetBy, toString, zip, zipWithIndex
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.eclipse.collections.api.bag.Bag
aggregateBy, collectWithOccurrences, reduceInPlace, reduceInPlace, summarizeDouble, summarizeFloat, summarizeInt, summarizeLong, toStringOfItemToCount
-
Methods inherited from interface java.util.Collection
addAll, containsAll, parallelStream, removeAll, removeIf, retainAll, spliterator, stream, toArray, toArray, toArray
-
Methods inherited from interface org.eclipse.collections.api.InternalIterable
forEach
-
Methods inherited from interface org.eclipse.collections.api.bag.MutableBag
collectBoolean, collectByte, collectChar, collectDouble, collectFloat, collectInt, collectLong, collectShort, flatCollectWith, selectDuplicates, selectUnique, toImmutableBag
-
Methods inherited from interface org.eclipse.collections.api.bag.MutableBagIterable
bottomOccurrences, selectDuplicates, selectUnique, topOccurrences
-
Methods inherited from interface org.eclipse.collections.api.collection.MutableCollection
addAllIterable, aggregateBy, aggregateInPlaceBy, collectBoolean, collectByte, collectChar, collectDouble, collectFloat, collectInt, collectLong, collectShort, flatCollectWith, groupByUniqueKey, injectIntoWith, retainAllIterable, selectAndRejectWith, sumByDouble, sumByFloat, sumByInt, sumByLong
-
Methods inherited from interface org.eclipse.collections.api.RichIterable
allSatisfy, allSatisfyWith, anySatisfy, anySatisfyWith, appendString, appendString, appendString, asLazy, chunk, collect, collectBoolean, collectByte, collectChar, collectDouble, collectFloat, collectIf, collectInt, collectLong, collectShort, collectWith, containsAll, containsAllArguments, containsAllIterable, containsAny, containsAnyIterable, containsBy, containsNone, containsNoneIterable, count, countBy, countByEach, countByWith, countWith, detect, detectIfNone, detectOptional, detectWith, detectWithIfNone, detectWithOptional, flatCollect, flatCollectBoolean, flatCollectByte, flatCollectChar, flatCollectDouble, flatCollectFloat, flatCollectInt, flatCollectLong, flatCollectShort, flatCollectWith, forEach, getAny, getFirst, getLast, getOnly, groupBy, groupByAndCollect, groupByEach, groupByUniqueKey, injectInto, injectInto, injectInto, injectInto, injectInto, injectIntoDouble, injectIntoFloat, injectIntoInt, injectIntoLong, into, makeString, makeString, makeString, makeString, max, max, maxBy, maxByOptional, maxOptional, maxOptional, min, min, minBy, minByOptional, minOptional, minOptional, noneSatisfy, noneSatisfyWith, notEmpty, reduce, reject, rejectWith, select, selectWith, sumOfDouble, sumOfFloat, sumOfInt, sumOfLong, toArray, toArray, toBag, toBiMap, toImmutableBiMap, toImmutableList, toImmutableMap, toImmutableSet, toImmutableSortedBag, toImmutableSortedBag, toImmutableSortedBagBy, toImmutableSortedList, toImmutableSortedList, toImmutableSortedListBy, toImmutableSortedSet, toImmutableSortedSet, toImmutableSortedSetBy, toList, toMap, toMap, toSet, toSortedBag, toSortedBag, toSortedBagBy, toSortedList, toSortedList, toSortedListBy, toSortedMap, toSortedMap, toSortedMapBy, toSortedSet, toSortedSet, toSortedSetBy, toString, zip, zipWithIndex
-
-
-
-
Field Detail
-
serialVersionUID
private static final long serialVersionUID
- See Also:
- Constant Field Values
-
hashingStrategy
private final HashingStrategy<? super T> hashingStrategy
-
-
Constructor Detail
-
HashBagWithHashingStrategy
public HashBagWithHashingStrategy(HashingStrategy<? super T> hashingStrategy)
-
HashBagWithHashingStrategy
public HashBagWithHashingStrategy(HashingStrategy<? super T> hashingStrategy, int size)
-
HashBagWithHashingStrategy
private HashBagWithHashingStrategy(HashingStrategy<? super T> hashingStrategy, MutableObjectIntMap<T> map)
-
-
Method Detail
-
newBag
public static <E> HashBagWithHashingStrategy<E> newBag(HashingStrategy<? super E> hashingStrategy)
-
newBag
public static <E> HashBagWithHashingStrategy<E> newBag(HashingStrategy<? super E> hashingStrategy, int size)
-
newBag
public static <E> HashBagWithHashingStrategy<E> newBag(HashingStrategy<? super E> hashingStrategy, Bag<? extends E> source)
-
newBag
public static <E> HashBagWithHashingStrategy<E> newBag(HashingStrategy<? super E> hashingStrategy, java.lang.Iterable<? extends E> source)
-
newBagWith
public static <E> HashBagWithHashingStrategy<E> newBagWith(HashingStrategy<? super E> hashingStrategy, E... elements)
-
hashingStrategy
public HashingStrategy<? super T> hashingStrategy()
-
computeHashCode
protected int computeHashCode(T item)
- Specified by:
computeHashCode
in classAbstractHashBag<T>
-
selectByOccurrences
public MutableBag<T> selectByOccurrences(IntPredicate predicate)
Description copied from interface:Bag
Returns all elements of the bag that have a number of occurrences that satisfy the predicate.- Specified by:
selectByOccurrences
in interfaceBag<T>
- Specified by:
selectByOccurrences
in interfaceMutableBag<T>
- Specified by:
selectByOccurrences
in interfaceMutableBagIterable<T>
- Specified by:
selectByOccurrences
in interfaceUnsortedBag<T>
-
writeReplace
protected java.lang.Object writeReplace()
-
with
public MutableBag<T> with(T element)
Description copied from interface:MutableCollection
This method allows mutable and fixed size collections the ability to add elements to their existing elements. In order to support fixed size a new instance of a collection would have to be returned taking the elements of the original collection and appending the new element to form the new collection. In the case of mutable collections, the original collection is modified, and is returned. In order to use this method properly with mutable and fixed size collections the following approach must be taken:MutableCollection<String> list = list.with("1"); list = list.with("2"); return list;
In the case ofFixedSizeCollection
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.- Specified by:
with
in interfaceMutableBag<T>
- Specified by:
with
in interfaceMutableBagIterable<T>
- Specified by:
with
in interfaceMutableCollection<T>
- See Also:
Collection.add(Object)
-
without
public MutableBag<T> without(T element)
Description copied from interface:MutableCollection
This method allows mutable and fixed size collections the ability to remove elements from their existing elements. In order to support fixed size a new instance of a collection would have to be returned containing the elements that would be left from the original collection after calling remove. In the case of mutable collections, the original collection is modified, and is returned. In order to use this method properly with mutable and fixed size collections the following approach must be taken:MutableCollection<String> list = list.without("1"); list = list.without("2"); return list;
In the case ofFixedSizeCollection
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.- Specified by:
without
in interfaceMutableBag<T>
- Specified by:
without
in interfaceMutableBagIterable<T>
- Specified by:
without
in interfaceMutableCollection<T>
- See Also:
Collection.remove(Object)
-
withAll
public MutableBag<T> withAll(java.lang.Iterable<? extends T> elements)
Description copied from interface:MutableCollection
This method allows mutable and fixed size collections the ability to add multiple elements to their existing elements. In order to support fixed size a new instance of a collection would have to be returned taking the elements of the original collection and appending the new elements to form the new collection. In the case of mutable collections, the original collection is modified, and is returned. In order to use this method properly with mutable and fixed size collections the following approach must be taken:MutableCollection<String> list = list.withAll(FastList.newListWith("1", "2"));
In the case ofFixedSizeCollection
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.- Specified by:
withAll
in interfaceMutableBag<T>
- Specified by:
withAll
in interfaceMutableBagIterable<T>
- Specified by:
withAll
in interfaceMutableCollection<T>
- See Also:
Collection.addAll(Collection)
-
withoutAll
public MutableBag<T> withoutAll(java.lang.Iterable<? extends T> elements)
Description copied from interface:MutableCollection
This method allows mutable and fixed size collections the ability to remove multiple elements from their existing elements. In order to support fixed size a new instance of a collection would have to be returned containing the elements that would be left from the original collection after calling removeAll. In the case of mutable collections, the original collection is modified, and is returned. In order to use this method properly with mutable and fixed size collections the following approach must be taken:MutableCollection<String> list = list.withoutAll(FastList.newListWith("1", "2"));
In the case ofFixedSizeCollection
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.- Specified by:
withoutAll
in interfaceMutableBag<T>
- Specified by:
withoutAll
in interfaceMutableBagIterable<T>
- Specified by:
withoutAll
in interfaceMutableCollection<T>
- See Also:
Collection.removeAll(Collection)
-
newEmpty
public MutableBag<T> newEmpty()
Description copied from interface:MutableCollection
Creates a new empty mutable version of the same collection type. For example, if this instance is a FastList, this method will return a new empty FastList. If the class of this instance is immutable or fixed size (i.e. SingletonList) then a mutable alternative to the class will be provided.- Specified by:
newEmpty
in interfaceMutableBag<T>
- Specified by:
newEmpty
in interfaceMutableCollection<T>
-
-