Top Description Methods
org.eclipse.collections.api.bag

public Interface MultiReaderBag<T>

extends MutableBag<T>
Imports
org.eclipse.collections.api.block.procedure.Procedure

A MultiReaderBag provides thread-safe iteration for a bag through methods withReadLockAndDelegate() and withWriteLockAndDelegate().
Since
10.0.

Method Summary

Modifier and TypeMethod and Description
public MultiReaderBag<T>
newEmpty()

Redeclares org.eclipse.collections.api.bag.MutableBag.newEmpty.

Creates a new empty mutable version of the same collection type.

public default MultiReaderBag<T>
tap(Procedure<? super T> procedure)

Implements org.eclipse.collections.api.bag.MutableBag.tap.

Executes the Procedure for each element in the iterable and returns this.

public default MultiReaderBag<T>
with(T element)

Overrides default org.eclipse.collections.api.bag.MutableBag.with.

This method allows mutable and fixed size collections the ability to add elements to their existing elements.

public default MultiReaderBag<T>
withAll(Iterable<? extends T> elements)

Overrides default org.eclipse.collections.api.bag.MutableBag.withAll.

This method allows mutable and fixed size collections the ability to add multiple elements to their existing elements.

public default MultiReaderBag<T>
public default MultiReaderBag<T>
without(T element)

Overrides default org.eclipse.collections.api.bag.MutableBag.without.

This method allows mutable and fixed size collections the ability to remove elements from their existing elements.

public default MultiReaderBag<T>
withoutAll(Iterable<? extends T> elements)

Overrides default org.eclipse.collections.api.bag.MutableBag.withoutAll.

This method allows mutable and fixed size collections the ability to remove multiple elements from their existing elements.

public default MultiReaderBag<T>
public void
public void
Inherited from org.eclipse.collections.api.bag.MutableBag:
asSynchronizedasUnmodifiablecollectcollectBooleancollectBytecollectCharcollectDoublecollectFloatcollectIfcollectIntcollectLongcollectShortcollectWithcollectWithOccurrencescountBycountByEachcountByWithflatCollectflatCollectWithgroupBygroupByEachpartitionpartitionWithrejectrejectWithselectselectByOccurrencesselectDuplicatesselectInstancesOfselectUniqueselectWithtoImmutabletoImmutableBagtoMapOfItemToCountzipzipWithIndex

Method Detail

newEmptyback to summary
public MultiReaderBag<T> newEmpty()

Redeclares org.eclipse.collections.api.bag.MutableBag.newEmpty.

Doc from org.eclipse.collections.api.collection.MutableCollection.newEmpty.

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.

Annotations
@Override
tapback to summary
public default MultiReaderBag<T> tap(Procedure<? super T> procedure)

Implements org.eclipse.collections.api.bag.MutableBag.tap.

Doc from org.eclipse.collections.api.RichIterable.tap.

Executes the Procedure for each element in the iterable and returns this.

Example using a Java 8 lambda expression:

RichIterable<Person> tapped =
    people.tap(person -> LOGGER.info(person.getName()));
Annotations
@Override
withback to summary
public default MultiReaderBag<T> with(T element)

Overrides default org.eclipse.collections.api.bag.MutableBag.with.

Doc from org.eclipse.collections.api.collection.MutableCollection.with.

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 of 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.
Annotations
@Override
withAllback to summary
public default MultiReaderBag<T> withAll(Iterable<? extends T> elements)

Overrides default org.eclipse.collections.api.bag.MutableBag.withAll.

Doc from org.eclipse.collections.api.collection.MutableCollection.withAll.

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 of 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.
Annotations
@Override
withOccurrencesback to summary
public default MultiReaderBag<T> withOccurrences(T element, int occurrences)

Overrides default org.eclipse.collections.api.bag.MutableBag.withOccurrences.

Annotations
@Override
withoutback to summary
public default MultiReaderBag<T> without(T element)

Overrides default org.eclipse.collections.api.bag.MutableBag.without.

Doc from org.eclipse.collections.api.collection.MutableCollection.without.

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 of 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.
Annotations
@Override
withoutAllback to summary
public default MultiReaderBag<T> withoutAll(Iterable<? extends T> elements)

Overrides default org.eclipse.collections.api.bag.MutableBag.withoutAll.

Doc from org.eclipse.collections.api.collection.MutableCollection.withoutAll.

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 of 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.
Annotations
@Override
withoutOccurrencesback to summary
public default MultiReaderBag<T> withoutOccurrences(T element, int occurrences)

Overrides default org.eclipse.collections.api.bag.MutableBag.withoutOccurrences.

Annotations
@Override
withReadLockAndDelegateback to summary
public void withReadLockAndDelegate(Procedure<? super MutableBag<T>> procedure)
withWriteLockAndDelegateback to summary
public void withWriteLockAndDelegate(Procedure<? super MutableBag<T>> procedure)