Package org.eclipse.collections.api.bag
Interface MultiReaderBag<T>
- All Superinterfaces:
Bag<T>,Collection<T>,InternalIterable<T>,Iterable<T>,MutableBag<T>,MutableBagIterable<T>,MutableCollection<T>,RichIterable<T>,UnsortedBag<T>
A MultiReaderBag provides thread-safe iteration for a bag through methods
withReadLockAndDelegate() and withWriteLockAndDelegate().- Since:
- 10.0.
-
Method Summary
Modifier and TypeMethodDescriptionnewEmpty()Creates a new empty mutable version of the same collection type.default MultiReaderBag<T>Executes the Procedure for each element in the iterable and returnsthis.default MultiReaderBag<T>This method allows mutable and fixed size collections the ability to add elements to their existing elements.default MultiReaderBag<T>This method allows mutable and fixed size collections the ability to add multiple elements to their existing elements.default MultiReaderBag<T>withOccurrences(T element, int occurrences) default MultiReaderBag<T>This method allows mutable and fixed size collections the ability to remove elements from their existing elements.default MultiReaderBag<T>withoutAll(Iterable<? extends T> elements) This method allows mutable and fixed size collections the ability to remove multiple elements from their existing elements.default MultiReaderBag<T>withoutOccurrences(T element, int occurrences) voidwithReadLockAndDelegate(Procedure<? super MutableBag<T>> procedure) voidwithWriteLockAndDelegate(Procedure<? super MutableBag<T>> procedure) Methods inherited from interface org.eclipse.collections.api.bag.Bag
aggregateBy, allSatisfyWithOccurrences, anySatisfyWithOccurrences, collectWithOccurrences, detectWithOccurrences, distinctView, equals, forEachWithOccurrences, hashCode, noneSatisfyWithOccurrences, occurrencesOf, reduceBy, reduceInPlace, reduceInPlace, sizeDistinct, summarizeDouble, summarizeFloat, summarizeInt, summarizeLong, toStringOfItemToCountMethods inherited from interface java.util.Collection
add, addAll, clear, contains, containsAll, equals, hashCode, isEmpty, iterator, parallelStream, remove, removeAll, removeIf, retainAll, size, spliterator, stream, toArrayMethods inherited from interface org.eclipse.collections.api.InternalIterable
forEach, forEachWith, forEachWithIndexMethods inherited from interface org.eclipse.collections.api.bag.MutableBag
asSynchronized, asUnmodifiable, collect, collectBoolean, collectByte, collectChar, collectDouble, collectFloat, collectIf, collectInt, collectLong, collectShort, collectWith, collectWithOccurrences, countBy, countByEach, countByWith, flatCollect, flatCollectWith, groupBy, groupByEach, partition, partitionWith, reject, rejectWith, select, selectByOccurrences, selectDuplicates, selectInstancesOf, selectUnique, selectWith, toImmutable, toImmutableBag, toMapOfItemToCount, zip, zipWithIndexMethods inherited from interface org.eclipse.collections.api.bag.MutableBagIterable
addOccurrences, bottomOccurrences, removeOccurrences, setOccurrences, topOccurrencesMethods inherited from interface org.eclipse.collections.api.collection.MutableCollection
addAllIterable, aggregateBy, aggregateInPlaceBy, groupByUniqueKey, injectIntoWith, removeAllIterable, removeIf, removeIfWith, retainAllIterable, selectAndRejectWith, sumByDouble, sumByFloat, sumByInt, sumByLong, toArray, toArrayMethods 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, reduceBy, 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
-
Method Details
-
withReadLockAndDelegate
-
withWriteLockAndDelegate
-
newEmpty
MultiReaderBag<T> newEmpty()Description copied from interface:MutableCollectionCreates 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:
newEmptyin interfaceMutableBag<T>- Specified by:
newEmptyin interfaceMutableCollection<T>
-
with
Description copied from interface:MutableCollectionThis 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 ofFixedSizeCollectiona 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:
within interfaceMutableBag<T>- Specified by:
within interfaceMutableBagIterable<T>- Specified by:
within interfaceMutableCollection<T>- See Also:
-
without
Description copied from interface:MutableCollectionThis 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 ofFixedSizeCollectiona 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:
withoutin interfaceMutableBag<T>- Specified by:
withoutin interfaceMutableBagIterable<T>- Specified by:
withoutin interfaceMutableCollection<T>- See Also:
-
withOccurrences
- Specified by:
withOccurrencesin interfaceMutableBag<T>- Specified by:
withOccurrencesin interfaceMutableBagIterable<T>
-
withoutOccurrences
- Specified by:
withoutOccurrencesin interfaceMutableBag<T>- Specified by:
withoutOccurrencesin interfaceMutableBagIterable<T>
-
withAll
Description copied from interface:MutableCollectionThis 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 ofFixedSizeCollectiona 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:
withAllin interfaceMutableBag<T>- Specified by:
withAllin interfaceMutableBagIterable<T>- Specified by:
withAllin interfaceMutableCollection<T>- See Also:
-
withoutAll
Description copied from interface:MutableCollectionThis 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 ofFixedSizeCollectiona 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:
withoutAllin interfaceMutableBag<T>- Specified by:
withoutAllin interfaceMutableBagIterable<T>- Specified by:
withoutAllin interfaceMutableCollection<T>- See Also:
-
tap
Description copied from interface:RichIterableExecutes the Procedure for each element in the iterable and returnsthis.Example using a Java 8 lambda expression:
RichIterable<Person> tapped = people.tap(person -> LOGGER.info(person.getName()));- Specified by:
tapin interfaceBag<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>- See Also:
-