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

public Interface MutableCollection<T>

extends Collection<T>, RichIterable<T>
Known Direct Subinterfaces
org.eclipse.collections.api.list.MutableList, org.eclipse.collections.api.set.MutableSetIterable, org.eclipse.collections.api.bag.MutableBagIterable, org.eclipse.collections.api.collection.FixedSizeCollection
Imports
java.util.Collection, org.eclipse.collections.api.RichIterable, org.eclipse.collections.api.bag.MutableBag, org.eclipse.collections.api.block.function.Function, .Function0, .Function2, .Function3, org.eclipse.collections.api.block.function.primitive.BooleanFunction, .ByteFunction, .CharFunction, .DoubleFunction, .FloatFunction, .IntFunction, .LongFunction, .ShortFunction, org.eclipse.collections.api.block.predicate.Predicate, .Predicate2, org.eclipse.collections.api.block.procedure.Procedure, .Procedure2, org.eclipse.collections.api.collection.primitive.MutableBooleanCollection, .MutableByteCollection, .MutableCharCollection, .MutableDoubleCollection, .MutableFloatCollection, .MutableIntCollection, .MutableLongCollection, .MutableShortCollection, org.eclipse.collections.api.factory.Maps, org.eclipse.collections.api.factory.primitive.BooleanLists, .ByteLists, .CharLists, .DoubleLists, .FloatLists, .IntLists, .LongLists, .ShortLists, org.eclipse.collections.api.list.MutableList, org.eclipse.collections.api.map.MutableMap, org.eclipse.collections.api.map.primitive.MutableObjectDoubleMap, .MutableObjectLongMap, org.eclipse.collections.api.multimap.MutableMultimap, org.eclipse.collections.api.ordered.OrderedIterable, org.eclipse.collections.api.partition.PartitionMutableCollection, org.eclipse.collections.api.tuple.Pair, .Twin

MutableCollection is an interface which extends the base java.util.Collection interface and adds several internal iterator methods, from the Smalltalk Collection protocol. These include variations of forEach, select, reject, detect, collect, injectInto, anySatisfy, allSatisfy. These include count, remove, partition, collectIf. The API also includes converter methods to convert a MutableCollection to a List (toList), to a sorted List (toSortedList), to a Set (toSet), and to a Map (toMap).

There are several extensions to MutableCollection, including MutableList, MutableSet, and MutableBag.

Method Summary

Modifier and TypeMethod and Description
public boolean
addAllIterable(Iterable<? extends T> iterable)

public default <K, V> MutableMap<K, V>
aggregateBy(Function<? super T, ? extends K> groupBy, Function0<? extends V> zeroValueFactory, Function2<? super V, ? super T, ? extends V> nonMutatingAggregator)

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

Applies an aggregate function over the iterable grouping results into a map based on the specific groupBy function.

public default <K, V> MutableMap<K, V>
aggregateInPlaceBy(Function<? super T, ? extends K> groupBy, Function0<? extends V> zeroValueFactory, Procedure2<? super V, ? super T> mutatingAggregator)

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

Applies an aggregate procedure over the iterable grouping results into a Map based on the specific groupBy function.

public MutableCollection<T>

Returns:

a synchronized view of this collection.
asSynchronized
()

Returns a synchronized wrapper backed by this collection.

public MutableCollection<T>

Returns:

an unmodifiable view of this collection.
asUnmodifiable
()

Returns an unmodifiable view of this collection.

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

Redeclares org.eclipse.collections.api.RichIterable.collect.

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

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

Implements 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 MutableByteCollection
collectByte(ByteFunction<? super T> byteFunction)

Implements 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 MutableCharCollection
collectChar(CharFunction<? super T> charFunction)

Implements 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 MutableDoubleCollection
collectDouble(DoubleFunction<? super T> doubleFunction)

Implements 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 MutableFloatCollection
collectFloat(FloatFunction<? super T> floatFunction)

Implements 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> MutableCollection<V>
collectIf(Predicate<? super T> predicate, Function<? super T, ? extends V> function)

Redeclares org.eclipse.collections.api.RichIterable.collectIf.

Returns a new MutableCollection with the results of applying the specified function to each element of the source collection, but only for elements that evaluate to true for the specified predicate.

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

Implements 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 MutableLongCollection
collectLong(LongFunction<? super T> longFunction)

Implements 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 MutableShortCollection
collectShort(ShortFunction<? super T> shortFunction)

Implements 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> MutableCollection<V>
collectWith(Function2<? super T, ? super P, ? extends V> function, P parameter)

Redeclares org.eclipse.collections.api.RichIterable.collectWith.

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

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

Overrides default org.eclipse.collections.api.RichIterable.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.

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.

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> MutableCollection<V>

Returns:

a new flattened collection produced by applying the given function
flatCollect
(Function<? super T, ? extends Iterable<V>>
The Function to apply
function
)

Redeclares org.eclipse.collections.api.RichIterable.flatCollect.

flatCollect is a special case of collect(Function).

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

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

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

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

Redeclares org.eclipse.collections.api.RichIterable.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> MutableMultimap<V, T>
groupByEach(Function<? super T, ? extends Iterable<V>> function)

Redeclares org.eclipse.collections.api.RichIterable.groupByEach.

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

public default <V> MutableMap<V, T>
groupByUniqueKey(Function<? super T, ? extends V> function)

Implements org.eclipse.collections.api.RichIterable.groupByUniqueKey.

For each element of the iterable, the function is evaluated, and the results of these evaluations are collected into a new map, where the transformed value is the key.

public <IV, P> IV
injectIntoWith(IV injectValue, Function3<? super IV, ? super T, ? super P, ? extends IV> function, P parameter)

Returns the final result of evaluating function using each element of the iterable, the previous evaluation result and the parameters.

public MutableCollection<T>
newEmpty()

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

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

Redeclares org.eclipse.collections.api.RichIterable.partition.

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

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

Redeclares org.eclipse.collections.api.RichIterable.partitionWith.

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

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

Redeclares org.eclipse.collections.api.RichIterable.reject.

Returns a MutableCollection with all elements that evaluate to false for the specified predicate.

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

Redeclares org.eclipse.collections.api.RichIterable.rejectWith.

Returns a MutableCollection with all elements that evaluate to false for the specified predicate2 and parameter.

public boolean
public boolean
removeIf(Predicate<? super T> predicate)

Removes all elements in the collection that evaluate to true for the specified predicate.

public <P> boolean
removeIfWith(Predicate2<? super T, ? super P> predicate, P parameter)

Removes all elements in the collection that evaluate to true for the specified predicate2 and parameter.

public boolean
public MutableCollection<T>
select(Predicate<? super T> predicate)

Redeclares org.eclipse.collections.api.RichIterable.select.

Returns a MutableCollection with all elements that evaluate to true for the specified predicate.

public <P> Twin<MutableList<T>>
selectAndRejectWith(Predicate2<? super T, ? super P> predicate, P parameter)
Deprecated since 6.0 use RichIterable#partitionWith(Predicate2, Object) instead.

Filters a collection into two separate collections based on a predicate returned via a Pair.

public <S> MutableCollection<S>
selectInstancesOf(Class<S> clazz)

Redeclares org.eclipse.collections.api.RichIterable.selectInstancesOf.

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

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

Redeclares org.eclipse.collections.api.RichIterable.selectWith.

Returns a MutableCollection with all elements that evaluate to true for the specified predicate2 and parameter.

public <V> MutableObjectDoubleMap<V>
sumByDouble(Function<? super T, ? extends V> groupBy, DoubleFunction<? super T> function)

Redeclares org.eclipse.collections.api.RichIterable.sumByDouble.

Groups and sums the values using the two specified functions.

public <V> MutableObjectDoubleMap<V>
sumByFloat(Function<? super T, ? extends V> groupBy, FloatFunction<? super T> function)

Redeclares org.eclipse.collections.api.RichIterable.sumByFloat.

Groups and sums the values using the two specified functions.

public <V> MutableObjectLongMap<V>
sumByInt(Function<? super T, ? extends V> groupBy, IntFunction<? super T> function)

Redeclares org.eclipse.collections.api.RichIterable.sumByInt.

Groups and sums the values using the two specified functions.

public <V> MutableObjectLongMap<V>
sumByLong(Function<? super T, ? extends V> groupBy, LongFunction<? super T> function)

Redeclares org.eclipse.collections.api.RichIterable.sumByLong.

Groups and sums the values using the two specified functions.

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

Redeclares org.eclipse.collections.api.RichIterable.tap.

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

public default Object[]
toArray()

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

Implements java.util.Collection.toArray.

Returns an array containing all of the elements in this collection.

public default <T1> T1[]
toArray(T1[] a)

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

Implements java.util.Collection.toArray.

Returns an array containing all of the elements in this collection; the runtime type of the returned array is that of the specified array.

public ImmutableCollection<T>
toImmutable()

Converts this MutableCollection to an ImmutableCollection.

public MutableCollection<T>
with(T element)

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

public MutableCollection<T>
withAll(Iterable<? extends T> elements)

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

public MutableCollection<T>
without(T element)

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

public MutableCollection<T>
withoutAll(Iterable<? extends T> elements)

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

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

Redeclares org.eclipse.collections.api.RichIterable.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 MutableCollection<Pair<T, Integer>>
zipWithIndex()

Redeclares org.eclipse.collections.api.RichIterable.zipWithIndex.

Deprecated in 6.0. Use OrderedIterable#zipWithIndex() instead.

Zips this RichIterable with its indices.

Inherited from java.util.Collection:
addaddAllclearcontainscontainsAllequalshashCodeisEmptyiteratorparallelStreamremoveremoveAllremoveIfretainAllsizespliteratorstreamtoArray
Inherited from org.eclipse.collections.api.RichIterable:
aggregateByallSatisfyallSatisfyWithanySatisfyanySatisfyWithappendStringappendStringappendStringasLazychunkcollectcollectBooleancollectBytecollectCharcollectDoublecollectFloatcollectIfcollectIntcollectLongcollectShortcollectWithcontainscontainsAllcontainsAllArgumentscontainsAllIterablecontainsAnycontainsAnyIterablecontainsBycontainsNonecontainsNoneIterablecountcountBycountByEachcountByWithcountWithdetectdetectIfNonedetectOptionaldetectWithdetectWithIfNonedetectWithOptionaleachflatCollectflatCollectBooleanflatCollectByteflatCollectCharflatCollectDoubleflatCollectFloatflatCollectIntflatCollectLongflatCollectShortflatCollectWithforEachgetAnygetFirstgetLastgetOnlygroupBygroupByAndCollectgroupByEachgroupByUniqueKeyinjectIntoinjectIntoinjectIntoinjectIntoinjectIntoinjectIntoDoubleinjectIntoFloatinjectIntoIntinjectIntoLongintoisEmptymakeStringmakeStringmakeStringmakeStringmaxmaxmaxBymaxByOptionalmaxOptionalmaxOptionalminminminByminByOptionalminOptionalminOptionalnoneSatisfynoneSatisfyWithnotEmptyreducereduceByreduceByreduceInPlacereduceInPlacerejectrejectWithselectselectWithsizesummarizeDoublesummarizeFloatsummarizeIntsummarizeLongsumOfDoublesumOfFloatsumOfIntsumOfLongtoBagtoBiMaptoImmutableBagtoImmutableBiMaptoImmutableListtoImmutableMaptoImmutableSettoImmutableSortedBagtoImmutableSortedBagtoImmutableSortedBagBytoImmutableSortedListtoImmutableSortedListtoImmutableSortedListBytoImmutableSortedSettoImmutableSortedSettoImmutableSortedSetBytoListtoMaptoMaptoSettoSortedBagtoSortedBagtoSortedBagBytoSortedListtoSortedListtoSortedListBytoSortedMaptoSortedMaptoSortedMapBytoSortedSettoSortedSettoSortedSetBytoStringzipzipWithIndex