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

public Interface MutableBag<T>

extends UnsortedBag<T>, MutableBagIterable<T>
Known Direct Subinterfaces
org.eclipse.collections.api.bag.MultiReaderBag
Imports
org.eclipse.collections.api.bag.primitive.MutableBooleanBag, .MutableByteBag, .MutableCharBag, .MutableDoubleBag, .MutableFloatBag, .MutableIntBag, .MutableLongBag, .MutableShortBag, org.eclipse.collections.api.block.function.Function, .Function2, org.eclipse.collections.api.block.function.primitive.BooleanFunction, .ByteFunction, .CharFunction, .DoubleFunction, .FloatFunction, .IntFunction, .LongFunction, .ObjectIntToObjectFunction, .ShortFunction, org.eclipse.collections.api.block.predicate.Predicate, .Predicate2, org.eclipse.collections.api.block.predicate.primitive.IntPredicate, org.eclipse.collections.api.block.procedure.Procedure, org.eclipse.collections.api.factory.Sets, org.eclipse.collections.api.factory.primitive.BooleanBags, .ByteBags, .CharBags, .DoubleBags, .FloatBags, .IntBags, .LongBags, .ShortBags, org.eclipse.collections.api.map.MutableMap, org.eclipse.collections.api.multimap.bag.MutableBagMultimap, org.eclipse.collections.api.ordered.OrderedIterable, org.eclipse.collections.api.partition.bag.PartitionMutableBag, org.eclipse.collections.api.set.MutableSet, org.eclipse.collections.api.tuple.Pair

A MutableBag is a Collection whose elements are unordered and may contain duplicate entries. It varies from MutableCollection in that it adds a protocol for determining, adding, and removing the number of occurrences for an item.
Since
1.0

Method Summary

Modifier and TypeMethod and Description
public MutableBag<T>
asSynchronized()

Redeclares org.eclipse.collections.api.collection.MutableCollection.asSynchronized.

Returns a synchronized wrapper backed by this collection.

public MutableBag<T>
asUnmodifiable()

Redeclares org.eclipse.collections.api.collection.MutableCollection.asUnmodifiable.

Returns an unmodifiable view of this collection.

public <V> MutableBag<V>
collect(Function<? super T, ? extends V> function)

Redeclares org.eclipse.collections.api.bag.UnsortedBag.collect, org.eclipse.collections.api.RichIterable.collect, org.eclipse.collections.api.collection.MutableCollection.collect.

Returns a new collection with the results of applying the specified function on each element of the source collection.

public default MutableBooleanBag
collectBoolean(BooleanFunction<? super T> booleanFunction)

Overrides default org.eclipse.collections.api.collection.MutableCollection.collectBoolean.

Implements org.eclipse.collections.api.bag.UnsortedBag.collectBoolean, org.eclipse.collections.api.RichIterable.collectBoolean.

Returns a new primitive boolean iterable with the results of applying the specified function on each element of the source collection.

public default MutableByteBag
collectByte(ByteFunction<? super T> byteFunction)

Overrides default org.eclipse.collections.api.collection.MutableCollection.collectByte.

Implements org.eclipse.collections.api.bag.UnsortedBag.collectByte, org.eclipse.collections.api.RichIterable.collectByte.

Returns a new primitive byte iterable with the results of applying the specified function on each element of the source collection.

public default MutableCharBag
collectChar(CharFunction<? super T> charFunction)

Overrides default org.eclipse.collections.api.collection.MutableCollection.collectChar.

Implements org.eclipse.collections.api.bag.UnsortedBag.collectChar, org.eclipse.collections.api.RichIterable.collectChar.

Returns a new primitive char iterable with the results of applying the specified function on each element of the source collection.

public default MutableDoubleBag
collectDouble(DoubleFunction<? super T> doubleFunction)

Overrides default org.eclipse.collections.api.collection.MutableCollection.collectDouble.

Implements org.eclipse.collections.api.bag.UnsortedBag.collectDouble, org.eclipse.collections.api.RichIterable.collectDouble.

Returns a new primitive double iterable with the results of applying the specified function on each element of the source collection.

public default MutableFloatBag
collectFloat(FloatFunction<? super T> floatFunction)

Overrides default org.eclipse.collections.api.collection.MutableCollection.collectFloat.

Implements org.eclipse.collections.api.bag.UnsortedBag.collectFloat, org.eclipse.collections.api.RichIterable.collectFloat.

Returns a new primitive float iterable with the results of applying the specified function on each element of the source collection.

public <V> MutableBag<V>
collectIf(Predicate<? super T> predicate, Function<? super T, ? extends V> function)

Redeclares org.eclipse.collections.api.bag.UnsortedBag.collectIf, org.eclipse.collections.api.RichIterable.collectIf, org.eclipse.collections.api.collection.MutableCollection.collectIf.

Returns a new collection with the results of applying the specified function on each element of the source collection, but only for those elements which return true upon evaluation of the predicate.

public default MutableIntBag
collectInt(IntFunction<? super T> intFunction)

Overrides default org.eclipse.collections.api.collection.MutableCollection.collectInt.

Implements org.eclipse.collections.api.bag.UnsortedBag.collectInt, org.eclipse.collections.api.RichIterable.collectInt.

Returns a new primitive int iterable with the results of applying the specified function on each element of the source collection.

public default MutableLongBag
collectLong(LongFunction<? super T> longFunction)

Overrides default org.eclipse.collections.api.collection.MutableCollection.collectLong.

Implements org.eclipse.collections.api.bag.UnsortedBag.collectLong, org.eclipse.collections.api.RichIterable.collectLong.

Returns a new primitive long iterable with the results of applying the specified function on each element of the source collection.

public default MutableShortBag
collectShort(ShortFunction<? super T> shortFunction)

Overrides default org.eclipse.collections.api.collection.MutableCollection.collectShort.

Implements org.eclipse.collections.api.bag.UnsortedBag.collectShort, org.eclipse.collections.api.RichIterable.collectShort.

Returns a new primitive short iterable with the results of applying the specified function on each element of the source collection.

public <P, V> MutableBag<V>
collectWith(Function2<? super T, ? super P, ? extends V> function, P parameter)

Redeclares org.eclipse.collections.api.bag.UnsortedBag.collectWith, org.eclipse.collections.api.RichIterable.collectWith, org.eclipse.collections.api.collection.MutableCollection.collectWith.

Same as collect(Function) with a Function2 and specified parameter which is passed to the block.

public <V> MutableBag<V>
collectWithOccurrences(ObjectIntToObjectFunction<? super T, ? extends V> function)

Redeclares org.eclipse.collections.api.bag.UnsortedBag.collectWithOccurrences, org.eclipse.collections.api.bag.MutableBagIterable.collectWithOccurrences.

Iterates over the unique elements and their occurrences and collects the results of applying the specified function.

public default <V> MutableBag<V>
countBy(Function<? super T, ? extends V> function)

Overrides default org.eclipse.collections.api.RichIterable.countBy, org.eclipse.collections.api.collection.MutableCollection.countBy.

This method will count the number of occurrences of each value calculated by applying the function to each element of the collection.

public default <V> MutableBag<V>
countByEach(Function<? super T, ? extends Iterable<V>> function)

Overrides default org.eclipse.collections.api.RichIterable.countByEach, org.eclipse.collections.api.collection.MutableCollection.countByEach.

This method will count the number of occurrences of each value calculated by applying the function to each element of the collection.

public default <V, P> MutableBag<V>
countByWith(Function2<? super T, ? super P, ? extends V> function, P parameter)

Overrides default org.eclipse.collections.api.RichIterable.countByWith, org.eclipse.collections.api.collection.MutableCollection.countByWith.

This method will count the number of occurrences of each value calculated by applying the function to each element of the collection with the specified parameter as the second argument.

public <V> MutableBag<V>
public default <P, V> MutableBag<V>
flatCollectWith(Function2<? super T, ? super P, ? extends Iterable<V>> function, P parameter)

Overrides default org.eclipse.collections.api.bag.UnsortedBag.flatCollectWith, org.eclipse.collections.api.RichIterable.flatCollectWith, org.eclipse.collections.api.collection.MutableCollection.flatCollectWith.

Same as flatCollect, only with a Function2 that is passed an extra parameter.

public <V> MutableBagMultimap<V, T>
groupBy(Function<? super T, ? extends V> function)

Redeclares org.eclipse.collections.api.bag.UnsortedBag.groupBy, org.eclipse.collections.api.bag.MutableBagIterable.groupBy.

For each element of the iterable, the function is evaluated and the results of these evaluations are collected into a new multimap, where the transformed value is the key and the original values are added to the same (or similar) species of collection as the source iterable.

public <V> MutableBagMultimap<V, T>
groupByEach(Function<? super T, ? extends Iterable<V>> function)

Redeclares org.eclipse.collections.api.bag.UnsortedBag.groupByEach, org.eclipse.collections.api.bag.MutableBagIterable.groupByEach.

Similar to groupBy(Function), except the result of evaluating function will return a collection of keys for each value.

public MutableBag<T>
newEmpty()

Redeclares org.eclipse.collections.api.collection.MutableCollection.newEmpty.

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

public PartitionMutableBag<T>
partition(Predicate<? super T> predicate)

Redeclares org.eclipse.collections.api.bag.UnsortedBag.partition, org.eclipse.collections.api.bag.MutableBagIterable.partition.

Filters a collection into a PartitionedIterable based on the evaluation of the predicate.

public <P> PartitionMutableBag<T>
partitionWith(Predicate2<? super T, ? super P> predicate, P parameter)

Redeclares org.eclipse.collections.api.bag.Bag.partitionWith, org.eclipse.collections.api.bag.MutableBagIterable.partitionWith.

Filters a collection into a PartitionIterable based on the evaluation of the predicate.

public MutableBag<T>
reject(Predicate<? super T> predicate)

Redeclares org.eclipse.collections.api.bag.UnsortedBag.reject, org.eclipse.collections.api.bag.MutableBagIterable.reject.

Returns all elements of the source collection that return false when evaluating of the predicate.

public <P> MutableBag<T>
rejectWith(Predicate2<? super T, ? super P> predicate, P parameter)

Redeclares org.eclipse.collections.api.bag.UnsortedBag.rejectWith, org.eclipse.collections.api.bag.MutableBagIterable.rejectWith.

Similar to reject(Predicate), except with an evaluation parameter for the second generic argument in Predicate2.

public MutableBag<T>
select(Predicate<? super T> predicate)

Redeclares org.eclipse.collections.api.bag.UnsortedBag.select, org.eclipse.collections.api.bag.MutableBagIterable.select.

Returns all elements of the source collection that return true when evaluating the predicate.

public MutableBag<T>
selectByOccurrences(IntPredicate predicate)

Redeclares org.eclipse.collections.api.bag.UnsortedBag.selectByOccurrences, org.eclipse.collections.api.bag.MutableBagIterable.selectByOccurrences.

Returns all elements of the bag that have a number of occurrences that satisfy the predicate.

public default MutableBag<T>
public <S> MutableBag<S>
selectInstancesOf(Class<S> clazz)

Redeclares org.eclipse.collections.api.bag.UnsortedBag.selectInstancesOf, org.eclipse.collections.api.bag.MutableBagIterable.selectInstancesOf.

Returns all elements of the source collection that are instances of the Class clazz.

public default MutableSet<T>
selectUnique()

Implements org.eclipse.collections.api.bag.UnsortedBag.selectUnique, org.eclipse.collections.api.bag.MutableBagIterable.selectUnique.

Returns a set containing all elements of the bag that have exactly one occurrence.

public <P> MutableBag<T>
selectWith(Predicate2<? super T, ? super P> predicate, P parameter)

Redeclares org.eclipse.collections.api.bag.UnsortedBag.selectWith, org.eclipse.collections.api.bag.MutableBagIterable.selectWith.

Similar to select(Predicate), except with an evaluation parameter for the second generic argument in Predicate2.

public MutableBag<T>
tap(Procedure<? super T> procedure)

Redeclares org.eclipse.collections.api.bag.UnsortedBag.tap, org.eclipse.collections.api.bag.MutableBagIterable.tap.

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

public ImmutableBag<T>
public default ImmutableBag<T>
toImmutableBag()

Overrides default org.eclipse.collections.api.RichIterable.toImmutableBag.

Converts the MutableBag to the default ImmutableBag implementation.

public MutableMap<T, Integer>
public default MutableBag<T>
with(T element)

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

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

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

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

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

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

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

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

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

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

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

public default MutableBag<T>
public <S> MutableBag<Pair<T, S>>
zip(Iterable<S> that)

Redeclares org.eclipse.collections.api.bag.UnsortedBag.zip, org.eclipse.collections.api.RichIterable.zip, org.eclipse.collections.api.collection.MutableCollection.zip.

Deprecated in 6.0. Use OrderedIterable#zip(Iterable) instead.

Returns a RichIterable formed from this RichIterable and another RichIterable by combining corresponding elements in pairs.

public MutableSet<Pair<T, Integer>>
Inherited from org.eclipse.collections.api.bag.MutableBagIterable:
addOccurrencesbottomOccurrencesremoveOccurrencessetOccurrencestopOccurrences