Class SynchronizedBag<T>
- java.lang.Object
-
- org.eclipse.collections.impl.collection.AbstractSynchronizedRichIterable<T>
-
- org.eclipse.collections.impl.collection.mutable.AbstractSynchronizedMutableCollection<T>
-
- org.eclipse.collections.impl.bag.mutable.SynchronizedBag<T>
-
- All Implemented Interfaces:
Serializable
,Iterable<T>
,Collection<T>
,Bag<T>
,MutableBag<T>
,MutableBagIterable<T>
,UnsortedBag<T>
,MutableCollection<T>
,InternalIterable<T>
,RichIterable<T>
public class SynchronizedBag<T> extends AbstractSynchronizedMutableCollection<T> implements MutableBag<T>, Serializable
A synchronized view of aMutableBag
. It is imperative that the user manually synchronize on the collection when iterating over it using the standard JDK iterator or JDK 5 for loop, as perCollections.synchronizedCollection(Collection)
.- Since:
- 1.0
- See Also:
MutableBag.asSynchronized()
, Serialized Form
-
-
Constructor Summary
Constructors Constructor Description SynchronizedBag(MutableBag<T> bag, Object newLock)
-
Method Summary
-
Methods inherited from class org.eclipse.collections.impl.collection.mutable.AbstractSynchronizedMutableCollection
add, addAll, addAllIterable, aggregateBy, aggregateInPlaceBy, clear, countBy, countByEach, countByWith, groupByUniqueKey, injectIntoWith, remove, removeAll, removeAllIterable, removeIf, removeIfWith, retainAll, retainAllIterable, selectAndRejectWith, sumByDouble, sumByFloat, sumByInt, sumByLong
-
Methods inherited from class org.eclipse.collections.impl.collection.AbstractSynchronizedRichIterable
allSatisfy, allSatisfyWith, anySatisfy, anySatisfyWith, appendString, appendString, appendString, asLazy, chunk, collect, collectBoolean, collectByte, collectChar, collectDouble, collectFloat, collectIf, collectInt, collectLong, collectShort, collectWith, contains, containsAll, containsAllArguments, containsAllIterable, containsAny, containsAnyIterable, containsNone, containsNoneIterable, count, countBy, countByEach, countByWith, countWith, detect, detectIfNone, detectOptional, detectWith, detectWithIfNone, detectWithOptional, each, equals, flatCollect, flatCollectBoolean, flatCollectByte, flatCollectChar, flatCollectDouble, flatCollectFloat, flatCollectInt, flatCollectLong, flatCollectShort, forEachWith, forEachWithIndex, getFirst, getLast, getOnly, groupBy, groupByEach, groupByUniqueKey, hashCode, injectInto, injectInto, injectInto, injectInto, injectInto, into, isEmpty, iterator, makeString, makeString, makeString, makeString, max, max, maxBy, maxByOptional, maxOptional, maxOptional, min, min, minBy, minByOptional, minOptional, minOptional, noneSatisfy, noneSatisfyWith, notEmpty, reject, rejectWith, select, selectWith, size, sumOfDouble, sumOfFloat, sumOfInt, sumOfLong, toArray, toArray, toBag, toBiMap, toImmutableBag, toImmutableList, toImmutableSet, toImmutableSortedBag, toImmutableSortedBag, toImmutableSortedBagBy, toImmutableSortedList, toImmutableSortedList, toImmutableSortedSet, toImmutableSortedSet, toImmutableSortedSetBy, toList, toMap, toMap, toSet, toSortedBag, toSortedBag, toSortedList, toSortedList, toSortedListBy, toSortedMap, toSortedMap, toSortedMapBy, toSortedSet, toSortedSet, toString, zip, zipWithIndex
-
Methods inherited from interface org.eclipse.collections.api.bag.Bag
aggregateBy, equals, hashCode, reduceInPlace, reduceInPlace, summarizeDouble, summarizeFloat, summarizeInt, summarizeLong
-
Methods inherited from interface java.util.Collection
add, addAll, clear, contains, containsAll, equals, hashCode, 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.MutableBag
countBy, countByEach, countByWith, flatCollectWith, selectDuplicates, toImmutableBag, with, withAll, without, withoutAll
-
Methods inherited from interface org.eclipse.collections.api.collection.MutableCollection
addAllIterable, aggregateBy, aggregateInPlaceBy, flatCollectWith, groupByUniqueKey, injectIntoWith, removeAllIterable, removeIf, removeIfWith, 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, 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
-
SynchronizedBag
public SynchronizedBag(MutableBag<T> bag, Object newLock)
-
-
Method Detail
-
of
public static <E,B extends MutableBag<E>> SynchronizedBag<E> of(B bag)
This method will take a MutableBag and wrap it directly in a SynchronizedBag.
-
of
public static <E,B extends MutableBag<E>> SynchronizedBag<E> of(B bag, Object lock)
This method will take a MutableBag and wrap it directly in a SynchronizedBag. Additionally, a developer specifies which lock to use with the collection.
-
newEmpty
public MutableBag<T> newEmpty()
- Specified by:
newEmpty
in interfaceMutableBag<T>
- Specified by:
newEmpty
in interfaceMutableCollection<T>
-
addOccurrences
public int addOccurrences(T item, int occurrences)
- Specified by:
addOccurrences
in interfaceMutableBagIterable<T>
-
removeOccurrences
public boolean removeOccurrences(Object item, int occurrences)
- Specified by:
removeOccurrences
in interfaceMutableBagIterable<T>
-
setOccurrences
public boolean setOccurrences(T item, int occurrences)
- Specified by:
setOccurrences
in interfaceMutableBagIterable<T>
-
toMapOfItemToCount
public MutableMap<T,Integer> toMapOfItemToCount()
- Specified by:
toMapOfItemToCount
in interfaceBag<T>
- Specified by:
toMapOfItemToCount
in interfaceMutableBag<T>
- Specified by:
toMapOfItemToCount
in interfaceMutableBagIterable<T>
-
selectByOccurrences
public MutableBag<T> selectByOccurrences(IntPredicate 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>
-
topOccurrences
public MutableList<ObjectIntPair<T>> topOccurrences(int count)
- Specified by:
topOccurrences
in interfaceBag<T>
- Specified by:
topOccurrences
in interfaceMutableBagIterable<T>
-
bottomOccurrences
public MutableList<ObjectIntPair<T>> bottomOccurrences(int count)
- Specified by:
bottomOccurrences
in interfaceBag<T>
- Specified by:
bottomOccurrences
in interfaceMutableBagIterable<T>
-
anySatisfyWithOccurrences
public boolean anySatisfyWithOccurrences(ObjectIntPredicate<? super T> predicate)
- Specified by:
anySatisfyWithOccurrences
in interfaceBag<T>
-
allSatisfyWithOccurrences
public boolean allSatisfyWithOccurrences(ObjectIntPredicate<? super T> predicate)
- Specified by:
allSatisfyWithOccurrences
in interfaceBag<T>
-
noneSatisfyWithOccurrences
public boolean noneSatisfyWithOccurrences(ObjectIntPredicate<? super T> predicate)
- Specified by:
noneSatisfyWithOccurrences
in interfaceBag<T>
-
detectWithOccurrences
public T detectWithOccurrences(ObjectIntPredicate<? super T> predicate)
- Specified by:
detectWithOccurrences
in interfaceBag<T>
-
forEachWithOccurrences
public void forEachWithOccurrences(ObjectIntProcedure<? super T> objectIntProcedure)
- Specified by:
forEachWithOccurrences
in interfaceBag<T>
-
collectWithOccurrences
public <V> MutableBag<V> collectWithOccurrences(ObjectIntToObjectFunction<? super T,? extends V> function)
- Specified by:
collectWithOccurrences
in interfaceBag<T>
- Specified by:
collectWithOccurrences
in interfaceMutableBag<T>
- Specified by:
collectWithOccurrences
in interfaceMutableBagIterable<T>
- Specified by:
collectWithOccurrences
in interfaceUnsortedBag<T>
-
collectWithOccurrences
public <V,R extends Collection<V>> R collectWithOccurrences(ObjectIntToObjectFunction<? super T,? extends V> function, R target)
- Specified by:
collectWithOccurrences
in interfaceBag<T>
- Since:
- 9.1.
-
occurrencesOf
public int occurrencesOf(Object item)
- Specified by:
occurrencesOf
in interfaceBag<T>
-
sizeDistinct
public int sizeDistinct()
- Specified by:
sizeDistinct
in interfaceBag<T>
-
toStringOfItemToCount
public String toStringOfItemToCount()
- Specified by:
toStringOfItemToCount
in interfaceBag<T>
-
tap
public MutableBag<T> tap(Procedure<? super T> procedure)
- Specified by:
tap
in interfaceBag<T>
- Specified by:
tap
in interfaceMutableBag<T>
- Specified by:
tap
in interfaceMutableBagIterable<T>
- Specified by:
tap
in interfaceMutableCollection<T>
- Specified by:
tap
in interfaceRichIterable<T>
- Specified by:
tap
in interfaceUnsortedBag<T>
- Overrides:
tap
in classAbstractSynchronizedMutableCollection<T>
-
select
public MutableBag<T> select(Predicate<? super T> predicate)
- Specified by:
select
in interfaceBag<T>
- Specified by:
select
in interfaceMutableBag<T>
- Specified by:
select
in interfaceMutableBagIterable<T>
- Specified by:
select
in interfaceMutableCollection<T>
- Specified by:
select
in interfaceRichIterable<T>
- Specified by:
select
in interfaceUnsortedBag<T>
- Overrides:
select
in classAbstractSynchronizedMutableCollection<T>
-
selectWith
public <P> MutableBag<T> selectWith(Predicate2<? super T,? super P> predicate, P parameter)
- Specified by:
selectWith
in interfaceBag<T>
- Specified by:
selectWith
in interfaceMutableBag<T>
- Specified by:
selectWith
in interfaceMutableBagIterable<T>
- Specified by:
selectWith
in interfaceMutableCollection<T>
- Specified by:
selectWith
in interfaceRichIterable<T>
- Specified by:
selectWith
in interfaceUnsortedBag<T>
- Overrides:
selectWith
in classAbstractSynchronizedMutableCollection<T>
-
reject
public MutableBag<T> reject(Predicate<? super T> predicate)
- Specified by:
reject
in interfaceBag<T>
- Specified by:
reject
in interfaceMutableBag<T>
- Specified by:
reject
in interfaceMutableBagIterable<T>
- Specified by:
reject
in interfaceMutableCollection<T>
- Specified by:
reject
in interfaceRichIterable<T>
- Specified by:
reject
in interfaceUnsortedBag<T>
- Overrides:
reject
in classAbstractSynchronizedMutableCollection<T>
-
rejectWith
public <P> MutableBag<T> rejectWith(Predicate2<? super T,? super P> predicate, P parameter)
- Specified by:
rejectWith
in interfaceBag<T>
- Specified by:
rejectWith
in interfaceMutableBag<T>
- Specified by:
rejectWith
in interfaceMutableBagIterable<T>
- Specified by:
rejectWith
in interfaceMutableCollection<T>
- Specified by:
rejectWith
in interfaceRichIterable<T>
- Specified by:
rejectWith
in interfaceUnsortedBag<T>
- Overrides:
rejectWith
in classAbstractSynchronizedMutableCollection<T>
-
partition
public PartitionMutableBag<T> partition(Predicate<? super T> predicate)
- Specified by:
partition
in interfaceBag<T>
- Specified by:
partition
in interfaceMutableBag<T>
- Specified by:
partition
in interfaceMutableBagIterable<T>
- Specified by:
partition
in interfaceMutableCollection<T>
- Specified by:
partition
in interfaceRichIterable<T>
- Specified by:
partition
in interfaceUnsortedBag<T>
- Overrides:
partition
in classAbstractSynchronizedMutableCollection<T>
-
partitionWith
public <P> PartitionMutableBag<T> partitionWith(Predicate2<? super T,? super P> predicate, P parameter)
- Specified by:
partitionWith
in interfaceBag<T>
- Specified by:
partitionWith
in interfaceMutableBag<T>
- Specified by:
partitionWith
in interfaceMutableBagIterable<T>
- Specified by:
partitionWith
in interfaceMutableCollection<T>
- Specified by:
partitionWith
in interfaceRichIterable<T>
- Overrides:
partitionWith
in classAbstractSynchronizedMutableCollection<T>
-
collectBoolean
public MutableBooleanBag collectBoolean(BooleanFunction<? super T> booleanFunction)
- Specified by:
collectBoolean
in interfaceMutableBag<T>
- Specified by:
collectBoolean
in interfaceMutableCollection<T>
- Specified by:
collectBoolean
in interfaceRichIterable<T>
- Specified by:
collectBoolean
in interfaceUnsortedBag<T>
- Overrides:
collectBoolean
in classAbstractSynchronizedMutableCollection<T>
-
collectByte
public MutableByteBag collectByte(ByteFunction<? super T> byteFunction)
- Specified by:
collectByte
in interfaceMutableBag<T>
- Specified by:
collectByte
in interfaceMutableCollection<T>
- Specified by:
collectByte
in interfaceRichIterable<T>
- Specified by:
collectByte
in interfaceUnsortedBag<T>
- Overrides:
collectByte
in classAbstractSynchronizedMutableCollection<T>
-
collectChar
public MutableCharBag collectChar(CharFunction<? super T> charFunction)
- Specified by:
collectChar
in interfaceMutableBag<T>
- Specified by:
collectChar
in interfaceMutableCollection<T>
- Specified by:
collectChar
in interfaceRichIterable<T>
- Specified by:
collectChar
in interfaceUnsortedBag<T>
- Overrides:
collectChar
in classAbstractSynchronizedMutableCollection<T>
-
collectDouble
public MutableDoubleBag collectDouble(DoubleFunction<? super T> doubleFunction)
- Specified by:
collectDouble
in interfaceMutableBag<T>
- Specified by:
collectDouble
in interfaceMutableCollection<T>
- Specified by:
collectDouble
in interfaceRichIterable<T>
- Specified by:
collectDouble
in interfaceUnsortedBag<T>
- Overrides:
collectDouble
in classAbstractSynchronizedMutableCollection<T>
-
collectFloat
public MutableFloatBag collectFloat(FloatFunction<? super T> floatFunction)
- Specified by:
collectFloat
in interfaceMutableBag<T>
- Specified by:
collectFloat
in interfaceMutableCollection<T>
- Specified by:
collectFloat
in interfaceRichIterable<T>
- Specified by:
collectFloat
in interfaceUnsortedBag<T>
- Overrides:
collectFloat
in classAbstractSynchronizedMutableCollection<T>
-
collectInt
public MutableIntBag collectInt(IntFunction<? super T> intFunction)
- Specified by:
collectInt
in interfaceMutableBag<T>
- Specified by:
collectInt
in interfaceMutableCollection<T>
- Specified by:
collectInt
in interfaceRichIterable<T>
- Specified by:
collectInt
in interfaceUnsortedBag<T>
- Overrides:
collectInt
in classAbstractSynchronizedMutableCollection<T>
-
collectLong
public MutableLongBag collectLong(LongFunction<? super T> longFunction)
- Specified by:
collectLong
in interfaceMutableBag<T>
- Specified by:
collectLong
in interfaceMutableCollection<T>
- Specified by:
collectLong
in interfaceRichIterable<T>
- Specified by:
collectLong
in interfaceUnsortedBag<T>
- Overrides:
collectLong
in classAbstractSynchronizedMutableCollection<T>
-
collectShort
public MutableShortBag collectShort(ShortFunction<? super T> shortFunction)
- Specified by:
collectShort
in interfaceMutableBag<T>
- Specified by:
collectShort
in interfaceMutableCollection<T>
- Specified by:
collectShort
in interfaceRichIterable<T>
- Specified by:
collectShort
in interfaceUnsortedBag<T>
- Overrides:
collectShort
in classAbstractSynchronizedMutableCollection<T>
-
selectInstancesOf
public <S> MutableBag<S> selectInstancesOf(Class<S> clazz)
- Specified by:
selectInstancesOf
in interfaceBag<T>
- Specified by:
selectInstancesOf
in interfaceMutableBag<T>
- Specified by:
selectInstancesOf
in interfaceMutableBagIterable<T>
- Specified by:
selectInstancesOf
in interfaceMutableCollection<T>
- Specified by:
selectInstancesOf
in interfaceRichIterable<T>
- Specified by:
selectInstancesOf
in interfaceUnsortedBag<T>
- Overrides:
selectInstancesOf
in classAbstractSynchronizedMutableCollection<T>
-
collect
public <V> MutableBag<V> collect(Function<? super T,? extends V> function)
- Specified by:
collect
in interfaceMutableBag<T>
- Specified by:
collect
in interfaceMutableCollection<T>
- Specified by:
collect
in interfaceRichIterable<T>
- Specified by:
collect
in interfaceUnsortedBag<T>
- Overrides:
collect
in classAbstractSynchronizedMutableCollection<T>
-
zipWithIndex
@Deprecated public MutableSet<Pair<T,Integer>> zipWithIndex()
Deprecated.in 6.0. UseOrderedIterable.zipWithIndex()
instead.- Specified by:
zipWithIndex
in interfaceBag<T>
- Specified by:
zipWithIndex
in interfaceMutableBag<T>
- Specified by:
zipWithIndex
in interfaceMutableBagIterable<T>
- Specified by:
zipWithIndex
in interfaceMutableCollection<T>
- Specified by:
zipWithIndex
in interfaceRichIterable<T>
- Specified by:
zipWithIndex
in interfaceUnsortedBag<T>
- Overrides:
zipWithIndex
in classAbstractSynchronizedMutableCollection<T>
-
collectWith
public <P,V> MutableBag<V> collectWith(Function2<? super T,? super P,? extends V> function, P parameter)
- Specified by:
collectWith
in interfaceMutableBag<T>
- Specified by:
collectWith
in interfaceMutableCollection<T>
- Specified by:
collectWith
in interfaceRichIterable<T>
- Specified by:
collectWith
in interfaceUnsortedBag<T>
- Overrides:
collectWith
in classAbstractSynchronizedMutableCollection<T>
-
collectIf
public <V> MutableBag<V> collectIf(Predicate<? super T> predicate, Function<? super T,? extends V> function)
- Specified by:
collectIf
in interfaceMutableBag<T>
- Specified by:
collectIf
in interfaceMutableCollection<T>
- Specified by:
collectIf
in interfaceRichIterable<T>
- Specified by:
collectIf
in interfaceUnsortedBag<T>
- Overrides:
collectIf
in classAbstractSynchronizedMutableCollection<T>
-
flatCollect
public <V> MutableBag<V> flatCollect(Function<? super T,? extends Iterable<V>> function)
- Specified by:
flatCollect
in interfaceMutableBag<T>
- Specified by:
flatCollect
in interfaceMutableCollection<T>
- Specified by:
flatCollect
in interfaceRichIterable<T>
- Specified by:
flatCollect
in interfaceUnsortedBag<T>
- Overrides:
flatCollect
in classAbstractSynchronizedMutableCollection<T>
-
groupBy
public <V> MutableBagMultimap<V,T> groupBy(Function<? super T,? extends V> function)
- Specified by:
groupBy
in interfaceBag<T>
- Specified by:
groupBy
in interfaceMutableBag<T>
- Specified by:
groupBy
in interfaceMutableBagIterable<T>
- Specified by:
groupBy
in interfaceMutableCollection<T>
- Specified by:
groupBy
in interfaceRichIterable<T>
- Specified by:
groupBy
in interfaceUnsortedBag<T>
- Overrides:
groupBy
in classAbstractSynchronizedMutableCollection<T>
-
groupByEach
public <V> MutableBagMultimap<V,T> groupByEach(Function<? super T,? extends Iterable<V>> function)
- Specified by:
groupByEach
in interfaceBag<T>
- Specified by:
groupByEach
in interfaceMutableBag<T>
- Specified by:
groupByEach
in interfaceMutableBagIterable<T>
- Specified by:
groupByEach
in interfaceMutableCollection<T>
- Specified by:
groupByEach
in interfaceRichIterable<T>
- Specified by:
groupByEach
in interfaceUnsortedBag<T>
- Overrides:
groupByEach
in classAbstractSynchronizedMutableCollection<T>
-
zip
@Deprecated public <S> MutableBag<Pair<T,S>> zip(Iterable<S> that)
Deprecated.in 6.0. UseOrderedIterable.zip(Iterable)
instead.- Specified by:
zip
in interfaceMutableBag<T>
- Specified by:
zip
in interfaceMutableCollection<T>
- Specified by:
zip
in interfaceRichIterable<T>
- Specified by:
zip
in interfaceUnsortedBag<T>
- Overrides:
zip
in classAbstractSynchronizedMutableCollection<T>
-
asUnmodifiable
public MutableBag<T> asUnmodifiable()
- Specified by:
asUnmodifiable
in interfaceMutableBag<T>
- Specified by:
asUnmodifiable
in interfaceMutableCollection<T>
-
asSynchronized
public MutableBag<T> asSynchronized()
- Specified by:
asSynchronized
in interfaceMutableBag<T>
- Specified by:
asSynchronized
in interfaceMutableCollection<T>
-
toImmutable
public ImmutableBag<T> toImmutable()
- Specified by:
toImmutable
in interfaceBag<T>
- Specified by:
toImmutable
in interfaceMutableBag<T>
- Specified by:
toImmutable
in interfaceMutableCollection<T>
-
selectUnique
public MutableSet<T> selectUnique()
- Specified by:
selectUnique
in interfaceBag<T>
- Specified by:
selectUnique
in interfaceMutableBag<T>
- Specified by:
selectUnique
in interfaceMutableBagIterable<T>
- Specified by:
selectUnique
in interfaceUnsortedBag<T>
-
distinctView
public RichIterable<T> distinctView()
- Specified by:
distinctView
in interfaceBag<T>
-
-