Class MultiReaderHashBag<T>
- java.lang.Object
-
- org.eclipse.collections.impl.collection.mutable.AbstractMultiReaderMutableCollection<T>
-
- org.eclipse.collections.impl.bag.mutable.MultiReaderHashBag<T>
-
- All Implemented Interfaces:
Externalizable,Serializable,Iterable<T>,Collection<T>,Bag<T>,MultiReaderBag<T>,MutableBag<T>,MutableBagIterable<T>,UnsortedBag<T>,MutableCollection<T>,InternalIterable<T>,RichIterable<T>
public final class MultiReaderHashBag<T> extends AbstractMultiReaderMutableCollection<T> implements Externalizable, MultiReaderBag<T>
MultiReaderHashBag provides a thread-safe wrapper around a HashBag, using a ReentrantReadWriteLock. In order to provide true thread-safety, MultiReaderHashBag does not implementiterator()as this method requires an external lock to be taken to provide thread-safe iteration. All of these methods are available however, if you use thewithReadLockAndDelegate()orwithWriteLockAndDelegate()methods. Both of these methods take a parameter of typeProcedure<MutableBag>, and a wrapped version of the underlying HashBag is returned. This wrapper guarantees that no external pointer can ever reference the underlying HashBag outside a locked procedure. In the case of the read lock method, an Unmodifiable version of the collection is offered, which will throw UnsupportedOperationExceptions on any write methods like add or remove.- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.eclipse.collections.impl.collection.mutable.AbstractMultiReaderMutableCollection
AbstractMultiReaderMutableCollection.LockWrapper, AbstractMultiReaderMutableCollection.ReadWriteLockWrapper
-
-
Constructor Summary
Constructors Constructor Description MultiReaderHashBag()Deprecated.Empty default constructor used for serialization.
-
Method Summary
-
Methods inherited from class org.eclipse.collections.impl.collection.mutable.AbstractMultiReaderMutableCollection
add, addAll, addAllIterable, aggregateInPlaceBy, allSatisfy, allSatisfyWith, anySatisfy, anySatisfyWith, appendString, appendString, appendString, asLazy, clear, collect, collectBoolean, collectByte, collectChar, collectDouble, collectFloat, collectIf, collectInt, collectLong, collectShort, collectWith, contains, containsAll, containsAllArguments, containsAllIterable, count, countWith, detect, detectIfNone, detectOptional, detectWith, detectWithIfNone, detectWithOptional, each, flatCollect, flatCollectBoolean, flatCollectByte, flatCollectChar, flatCollectDouble, flatCollectFloat, flatCollectInt, flatCollectLong, flatCollectShort, forEachWith, forEachWithIndex, getFirst, getLast, getOnly, groupBy, groupByEach, groupByUniqueKey, injectInto, injectInto, injectInto, injectInto, injectInto, injectIntoWith, into, isEmpty, iterator, makeString, makeString, makeString, makeString, max, max, maxBy, maxByOptional, maxOptional, maxOptional, min, min, minBy, minByOptional, minOptional, minOptional, noneSatisfy, noneSatisfyWith, notEmpty, parallelStream, reject, rejectWith, remove, removeAll, removeAllIterable, removeIf, removeIfWith, retainAll, retainAllIterable, select, selectAndRejectWith, selectWith, size, spliterator, stream, sumByDouble, sumByFloat, sumOfDouble, sumOfFloat, sumOfInt, sumOfLong, toArray, toArray, toBag, toBiMap, toImmutableBag, toImmutableList, toImmutableSet, toImmutableSortedBag, toImmutableSortedBag, toImmutableSortedBagBy, toImmutableSortedList, toImmutableSortedList, toImmutableSortedListBy, toImmutableSortedSet, toImmutableSortedSet, toImmutableSortedSetBy, toList, toMap, toMap, toSet, toSortedBag, toSortedBag, toSortedList, toSortedList, toSortedListBy, toSortedMap, toSortedMap, toSortedSet, toSortedSet, toSortedSetBy, toString, zip, zipWithIndex
-
Methods inherited from interface org.eclipse.collections.api.bag.Bag
aggregateBy, reduceInPlace, reduceInPlace, summarizeDouble, summarizeFloat, summarizeInt, summarizeLong
-
Methods inherited from interface java.util.Collection
add, addAll, clear, contains, containsAll, isEmpty, iterator, parallelStream, remove, removeAll, removeIf, retainAll, size, spliterator, stream, toArray, toArray, toArray
-
Methods inherited from interface org.eclipse.collections.api.InternalIterable
forEach, forEachWith, forEachWithIndex
-
Methods inherited from interface org.eclipse.collections.api.bag.MultiReaderBag
with, withAll, without, withoutAll
-
Methods inherited from interface org.eclipse.collections.api.bag.MutableBag
countBy, countByEach, countByWith, flatCollectWith, selectDuplicates, toImmutableBag
-
Methods inherited from interface org.eclipse.collections.api.collection.MutableCollection
addAllIterable, aggregateBy, aggregateInPlaceBy, flatCollectWith, injectIntoWith, removeAllIterable, removeIf, removeIfWith, retainAllIterable, selectAndRejectWith, sumByDouble, sumByFloat
-
Methods inherited from interface org.eclipse.collections.api.RichIterable
allSatisfy, allSatisfyWith, anySatisfy, anySatisfyWith, appendString, appendString, appendString, asLazy, collect, collectBoolean, collectByte, collectChar, collectDouble, collectFloat, collectIf, collectInt, collectLong, collectShort, collectWith, contains, containsAll, containsAllArguments, containsAllIterable, containsAny, containsAnyIterable, containsBy, containsNone, containsNoneIterable, count, countBy, countByEach, countByWith, countWith, detect, detectIfNone, detectOptional, detectWith, detectWithIfNone, detectWithOptional, each, 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, isEmpty, makeString, makeString, makeString, makeString, max, max, maxBy, maxByOptional, maxOptional, maxOptional, min, min, minBy, minByOptional, minOptional, minOptional, noneSatisfy, noneSatisfyWith, notEmpty, reduce, reject, rejectWith, select, selectWith, size, 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
-
-
-
-
Constructor Detail
-
MultiReaderHashBag
@Deprecated public MultiReaderHashBag()
Deprecated.Empty default constructor used for serialization.
-
-
Method Detail
-
newBag
public static <T> MultiReaderHashBag<T> newBag()
-
newBag
public static <T> MultiReaderHashBag<T> newBag(int capacity)
-
newBag
public static <T> MultiReaderHashBag<T> newBag(Iterable<T> iterable)
-
newBagWith
public static <T> MultiReaderHashBag<T> newBagWith(T... elements)
-
trimToSize
public void trimToSize()
Rehashes every element in the set into a new backing table of the smallest possible size and eliminating removed sentinels.- Since:
- 12.0
-
withReadLockAndDelegate
public void withReadLockAndDelegate(Procedure<? super MutableBag<T>> procedure)
- Specified by:
withReadLockAndDelegatein interfaceMultiReaderBag<T>
-
withWriteLockAndDelegate
public void withWriteLockAndDelegate(Procedure<? super MutableBag<T>> procedure)
- Specified by:
withWriteLockAndDelegatein interfaceMultiReaderBag<T>
-
asSynchronized
public MutableBag<T> asSynchronized()
- Specified by:
asSynchronizedin interfaceMutableBag<T>- Specified by:
asSynchronizedin interfaceMutableCollection<T>
-
asUnmodifiable
public MutableBag<T> asUnmodifiable()
- Specified by:
asUnmodifiablein interfaceMutableBag<T>- Specified by:
asUnmodifiablein interfaceMutableCollection<T>
-
toImmutable
public ImmutableBag<T> toImmutable()
- Specified by:
toImmutablein interfaceBag<T>- Specified by:
toImmutablein interfaceMutableBag<T>- Specified by:
toImmutablein interfaceMutableCollection<T>
-
addOccurrences
public int addOccurrences(T item, int occurrences)
- Specified by:
addOccurrencesin interfaceMutableBagIterable<T>
-
removeOccurrences
public boolean removeOccurrences(Object item, int occurrences)
- Specified by:
removeOccurrencesin interfaceMutableBagIterable<T>
-
setOccurrences
public boolean setOccurrences(T item, int occurrences)
- Specified by:
setOccurrencesin interfaceMutableBagIterable<T>
-
occurrencesOf
public int occurrencesOf(Object item)
- Specified by:
occurrencesOfin interfaceBag<T>
-
sizeDistinct
public int sizeDistinct()
- Specified by:
sizeDistinctin interfaceBag<T>
-
collect
public <V> MutableBag<V> collect(Function<? super T,? extends V> function)
- Specified by:
collectin interfaceMutableBag<T>- Specified by:
collectin interfaceMutableCollection<T>- Specified by:
collectin interfaceRichIterable<T>- Specified by:
collectin interfaceUnsortedBag<T>
-
collectBoolean
public MutableBooleanBag collectBoolean(BooleanFunction<? super T> booleanFunction)
- Specified by:
collectBooleanin interfaceMutableBag<T>- Specified by:
collectBooleanin interfaceMutableCollection<T>- Specified by:
collectBooleanin interfaceRichIterable<T>- Specified by:
collectBooleanin interfaceUnsortedBag<T>
-
collectByte
public MutableByteBag collectByte(ByteFunction<? super T> byteFunction)
- Specified by:
collectBytein interfaceMutableBag<T>- Specified by:
collectBytein interfaceMutableCollection<T>- Specified by:
collectBytein interfaceRichIterable<T>- Specified by:
collectBytein interfaceUnsortedBag<T>
-
collectChar
public MutableCharBag collectChar(CharFunction<? super T> charFunction)
- Specified by:
collectCharin interfaceMutableBag<T>- Specified by:
collectCharin interfaceMutableCollection<T>- Specified by:
collectCharin interfaceRichIterable<T>- Specified by:
collectCharin interfaceUnsortedBag<T>
-
collectDouble
public MutableDoubleBag collectDouble(DoubleFunction<? super T> doubleFunction)
- Specified by:
collectDoublein interfaceMutableBag<T>- Specified by:
collectDoublein interfaceMutableCollection<T>- Specified by:
collectDoublein interfaceRichIterable<T>- Specified by:
collectDoublein interfaceUnsortedBag<T>
-
collectFloat
public MutableFloatBag collectFloat(FloatFunction<? super T> floatFunction)
- Specified by:
collectFloatin interfaceMutableBag<T>- Specified by:
collectFloatin interfaceMutableCollection<T>- Specified by:
collectFloatin interfaceRichIterable<T>- Specified by:
collectFloatin interfaceUnsortedBag<T>
-
collectInt
public MutableIntBag collectInt(IntFunction<? super T> intFunction)
- Specified by:
collectIntin interfaceMutableBag<T>- Specified by:
collectIntin interfaceMutableCollection<T>- Specified by:
collectIntin interfaceRichIterable<T>- Specified by:
collectIntin interfaceUnsortedBag<T>
-
collectLong
public MutableLongBag collectLong(LongFunction<? super T> longFunction)
- Specified by:
collectLongin interfaceMutableBag<T>- Specified by:
collectLongin interfaceMutableCollection<T>- Specified by:
collectLongin interfaceRichIterable<T>- Specified by:
collectLongin interfaceUnsortedBag<T>
-
collectShort
public MutableShortBag collectShort(ShortFunction<? super T> shortFunction)
- Specified by:
collectShortin interfaceMutableBag<T>- Specified by:
collectShortin interfaceMutableCollection<T>- Specified by:
collectShortin interfaceRichIterable<T>- Specified by:
collectShortin interfaceUnsortedBag<T>
-
flatCollect
public <V> MutableBag<V> flatCollect(Function<? super T,? extends Iterable<V>> function)
- Specified by:
flatCollectin interfaceMutableBag<T>- Specified by:
flatCollectin interfaceMutableCollection<T>- Specified by:
flatCollectin interfaceRichIterable<T>- Specified by:
flatCollectin interfaceUnsortedBag<T>
-
topOccurrences
public MutableList<ObjectIntPair<T>> topOccurrences(int count)
- Specified by:
topOccurrencesin interfaceBag<T>- Specified by:
topOccurrencesin interfaceMutableBagIterable<T>
-
bottomOccurrences
public MutableList<ObjectIntPair<T>> bottomOccurrences(int count)
- Specified by:
bottomOccurrencesin interfaceBag<T>- Specified by:
bottomOccurrencesin interfaceMutableBagIterable<T>
-
collectIf
public <V> MutableBag<V> collectIf(Predicate<? super T> predicate, Function<? super T,? extends V> function)
- Specified by:
collectIfin interfaceMutableBag<T>- Specified by:
collectIfin interfaceMutableCollection<T>- Specified by:
collectIfin interfaceRichIterable<T>- Specified by:
collectIfin interfaceUnsortedBag<T>
-
collectWithOccurrences
public <V> MutableBag<V> collectWithOccurrences(ObjectIntToObjectFunction<? super T,? extends V> function)
- Specified by:
collectWithOccurrencesin interfaceBag<T>- Specified by:
collectWithOccurrencesin interfaceMutableBag<T>- Specified by:
collectWithOccurrencesin interfaceMutableBagIterable<T>- Specified by:
collectWithOccurrencesin interfaceUnsortedBag<T>
-
collectWithOccurrences
public <V,R extends Collection<V>> R collectWithOccurrences(ObjectIntToObjectFunction<? super T,? extends V> function, R target)
- Specified by:
collectWithOccurrencesin interfaceBag<T>
-
collectWith
public <P,V> MutableBag<V> collectWith(Function2<? super T,? super P,? extends V> function, P parameter)
- Specified by:
collectWithin interfaceMutableBag<T>- Specified by:
collectWithin interfaceMutableCollection<T>- Specified by:
collectWithin interfaceRichIterable<T>- Specified by:
collectWithin interfaceUnsortedBag<T>
-
newEmpty
public MultiReaderBag<T> newEmpty()
- Specified by:
newEmptyin interfaceMultiReaderBag<T>- Specified by:
newEmptyin interfaceMutableBag<T>- Specified by:
newEmptyin interfaceMutableCollection<T>
-
reject
public MutableBag<T> reject(Predicate<? super T> predicate)
- Specified by:
rejectin interfaceBag<T>- Specified by:
rejectin interfaceMutableBag<T>- Specified by:
rejectin interfaceMutableBagIterable<T>- Specified by:
rejectin interfaceMutableCollection<T>- Specified by:
rejectin interfaceRichIterable<T>- Specified by:
rejectin interfaceUnsortedBag<T>
-
rejectWith
public <P> MutableBag<T> rejectWith(Predicate2<? super T,? super P> predicate, P parameter)
- Specified by:
rejectWithin interfaceBag<T>- Specified by:
rejectWithin interfaceMutableBag<T>- Specified by:
rejectWithin interfaceMutableBagIterable<T>- Specified by:
rejectWithin interfaceMutableCollection<T>- Specified by:
rejectWithin interfaceRichIterable<T>- Specified by:
rejectWithin interfaceUnsortedBag<T>
-
tap
public MultiReaderBag<T> tap(Procedure<? super T> procedure)
- Specified by:
tapin interfaceBag<T>- Specified by:
tapin interfaceMultiReaderBag<T>- Specified by:
tapin interfaceMutableBag<T>- Specified by:
tapin interfaceMutableBagIterable<T>- Specified by:
tapin interfaceMutableCollection<T>- Specified by:
tapin interfaceRichIterable<T>- Specified by:
tapin interfaceUnsortedBag<T>
-
select
public MutableBag<T> select(Predicate<? super T> predicate)
- Specified by:
selectin interfaceBag<T>- Specified by:
selectin interfaceMutableBag<T>- Specified by:
selectin interfaceMutableBagIterable<T>- Specified by:
selectin interfaceMutableCollection<T>- Specified by:
selectin interfaceRichIterable<T>- Specified by:
selectin interfaceUnsortedBag<T>
-
selectWith
public <P> MutableBag<T> selectWith(Predicate2<? super T,? super P> predicate, P parameter)
- Specified by:
selectWithin interfaceBag<T>- Specified by:
selectWithin interfaceMutableBag<T>- Specified by:
selectWithin interfaceMutableBagIterable<T>- Specified by:
selectWithin interfaceMutableCollection<T>- Specified by:
selectWithin interfaceRichIterable<T>- Specified by:
selectWithin interfaceUnsortedBag<T>
-
selectByOccurrences
public MutableBag<T> selectByOccurrences(IntPredicate predicate)
- Specified by:
selectByOccurrencesin interfaceBag<T>- Specified by:
selectByOccurrencesin interfaceMutableBag<T>- Specified by:
selectByOccurrencesin interfaceMutableBagIterable<T>- Specified by:
selectByOccurrencesin interfaceUnsortedBag<T>
-
selectInstancesOf
public <S> MutableBag<S> selectInstancesOf(Class<S> clazz)
- Specified by:
selectInstancesOfin interfaceBag<T>- Specified by:
selectInstancesOfin interfaceMutableBag<T>- Specified by:
selectInstancesOfin interfaceMutableBagIterable<T>- Specified by:
selectInstancesOfin interfaceMutableCollection<T>- Specified by:
selectInstancesOfin interfaceRichIterable<T>- Specified by:
selectInstancesOfin interfaceUnsortedBag<T>
-
partition
public PartitionMutableBag<T> partition(Predicate<? super T> predicate)
- Specified by:
partitionin interfaceBag<T>- Specified by:
partitionin interfaceMutableBag<T>- Specified by:
partitionin interfaceMutableBagIterable<T>- Specified by:
partitionin interfaceMutableCollection<T>- Specified by:
partitionin interfaceRichIterable<T>- Specified by:
partitionin interfaceUnsortedBag<T>
-
partitionWith
public <P> PartitionMutableBag<T> partitionWith(Predicate2<? super T,? super P> predicate, P parameter)
- Specified by:
partitionWithin interfaceBag<T>- Specified by:
partitionWithin interfaceMutableBag<T>- Specified by:
partitionWithin interfaceMutableBagIterable<T>- Specified by:
partitionWithin interfaceMutableCollection<T>- Specified by:
partitionWithin interfaceRichIterable<T>
-
toMapOfItemToCount
public MutableMap<T,Integer> toMapOfItemToCount()
- Specified by:
toMapOfItemToCountin interfaceBag<T>- Specified by:
toMapOfItemToCountin interfaceMutableBag<T>- Specified by:
toMapOfItemToCountin interfaceMutableBagIterable<T>
-
toStringOfItemToCount
public String toStringOfItemToCount()
- Specified by:
toStringOfItemToCountin interfaceBag<T>
-
groupBy
public <V> MutableBagMultimap<V,T> groupBy(Function<? super T,? extends V> function)
- Specified by:
groupByin interfaceBag<T>- Specified by:
groupByin interfaceMutableBag<T>- Specified by:
groupByin interfaceMutableBagIterable<T>- Specified by:
groupByin interfaceMutableCollection<T>- Specified by:
groupByin interfaceRichIterable<T>- Specified by:
groupByin interfaceUnsortedBag<T>
-
groupByEach
public <V> MutableBagMultimap<V,T> groupByEach(Function<? super T,? extends Iterable<V>> function)
- Specified by:
groupByEachin interfaceBag<T>- Specified by:
groupByEachin interfaceMutableBag<T>- Specified by:
groupByEachin interfaceMutableBagIterable<T>- Specified by:
groupByEachin interfaceMutableCollection<T>- Specified by:
groupByEachin interfaceRichIterable<T>- Specified by:
groupByEachin interfaceUnsortedBag<T>
-
groupByUniqueKey
public <V> MutableMap<V,T> groupByUniqueKey(Function<? super T,? extends V> function)
- Specified by:
groupByUniqueKeyin interfaceMutableCollection<T>- Specified by:
groupByUniqueKeyin interfaceRichIterable<T>
-
zip
@Deprecated public <S> MutableBag<Pair<T,S>> zip(Iterable<S> that)
Deprecated.in 6.0. UseOrderedIterable.zip(Iterable)instead.- Specified by:
zipin interfaceMutableBag<T>- Specified by:
zipin interfaceMutableCollection<T>- Specified by:
zipin interfaceRichIterable<T>- Specified by:
zipin interfaceUnsortedBag<T>
-
zipWithIndex
@Deprecated public MutableSet<Pair<T,Integer>> zipWithIndex()
Deprecated.in 6.0. UseOrderedIterable.zipWithIndex()instead.- Specified by:
zipWithIndexin interfaceBag<T>- Specified by:
zipWithIndexin interfaceMutableBag<T>- Specified by:
zipWithIndexin interfaceMutableBagIterable<T>- Specified by:
zipWithIndexin interfaceMutableCollection<T>- Specified by:
zipWithIndexin interfaceRichIterable<T>- Specified by:
zipWithIndexin interfaceUnsortedBag<T>
-
chunk
public RichIterable<RichIterable<T>> chunk(int size)
- Specified by:
chunkin interfaceRichIterable<T>
-
anySatisfyWithOccurrences
public boolean anySatisfyWithOccurrences(ObjectIntPredicate<? super T> predicate)
- Specified by:
anySatisfyWithOccurrencesin interfaceBag<T>
-
allSatisfyWithOccurrences
public boolean allSatisfyWithOccurrences(ObjectIntPredicate<? super T> predicate)
- Specified by:
allSatisfyWithOccurrencesin interfaceBag<T>
-
noneSatisfyWithOccurrences
public boolean noneSatisfyWithOccurrences(ObjectIntPredicate<? super T> predicate)
- Specified by:
noneSatisfyWithOccurrencesin interfaceBag<T>
-
detectWithOccurrences
public T detectWithOccurrences(ObjectIntPredicate<? super T> predicate)
- Specified by:
detectWithOccurrencesin interfaceBag<T>
-
sumByInt
public <V> MutableObjectLongMap<V> sumByInt(Function<? super T,? extends V> groupBy, IntFunction<? super T> function)
- Specified by:
sumByIntin interfaceMutableCollection<T>- Specified by:
sumByIntin interfaceRichIterable<T>- Overrides:
sumByIntin classAbstractMultiReaderMutableCollection<T>
-
sumByLong
public <V> MutableObjectLongMap<V> sumByLong(Function<? super T,? extends V> groupBy, LongFunction<? super T> function)
- Specified by:
sumByLongin interfaceMutableCollection<T>- Specified by:
sumByLongin interfaceRichIterable<T>- Overrides:
sumByLongin classAbstractMultiReaderMutableCollection<T>
-
forEachWithOccurrences
public void forEachWithOccurrences(ObjectIntProcedure<? super T> procedure)
- Specified by:
forEachWithOccurrencesin interfaceBag<T>
-
equals
public boolean equals(Object o)
-
hashCode
public int hashCode()
-
writeExternal
public void writeExternal(ObjectOutput out) throws IOException
- Specified by:
writeExternalin interfaceExternalizable- Throws:
IOException
-
readExternal
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
- Specified by:
readExternalin interfaceExternalizable- Throws:
IOExceptionClassNotFoundException
-
selectUnique
public MutableSet<T> selectUnique()
- Specified by:
selectUniquein interfaceBag<T>- Specified by:
selectUniquein interfaceMutableBag<T>- Specified by:
selectUniquein interfaceMutableBagIterable<T>- Specified by:
selectUniquein interfaceUnsortedBag<T>
-
distinctView
public RichIterable<T> distinctView()
- Specified by:
distinctViewin interfaceBag<T>
-
-