Top Constructors Methods
org.eclipse.collections.impl.collection.mutable

public abstract Class AbstractMutableCollection<T>

extends AbstractRichIterable<T>
implements MutableCollection<T>
Class Inheritance
All Implemented Interfaces
org.eclipse.collections.api.collection.MutableCollection, org.eclipse.collections.api.RichIterable, org.eclipse.collections.api.InternalIterable, java.lang.Iterable, java.util.Collection
Known Direct Subclasses
org.eclipse.collections.impl.list.mutable.AbstractMutableList, org.eclipse.collections.impl.set.AbstractUnifiedSet, org.eclipse.collections.impl.set.mutable.AbstractMutableSet, org.eclipse.collections.impl.set.sorted.mutable.TreeSortedSet
Imports
java.util.Collection, .Iterator, .List, .Objects, .Optional, .RandomAccess, java.util.function.BinaryOperator, org.eclipse.collections.api.RichIterable, org.eclipse.collections.api.bag.MutableBag, org.eclipse.collections.api.block.function.Function, .Function2, .Function3, org.eclipse.collections.api.block.function.primitive.DoubleFunction, .FloatFunction, .IntFunction, .LongFunction, org.eclipse.collections.api.block.predicate.Predicate, .Predicate2, org.eclipse.collections.api.collection.MutableCollection, org.eclipse.collections.api.factory.Bags, .Lists, org.eclipse.collections.api.factory.primitive.ObjectDoubleMaps, .ObjectLongMaps, org.eclipse.collections.api.list.MutableList, org.eclipse.collections.api.map.MutableMap, org.eclipse.collections.api.map.primitive.MutableObjectDoubleMap, .MutableObjectLongMap, org.eclipse.collections.api.tuple.Twin, org.eclipse.collections.impl.AbstractRichIterable, org.eclipse.collections.impl.block.factory.PrimitiveFunctions, .Procedures2, org.eclipse.collections.impl.utility.Iterate, org.eclipse.collections.impl.utility.internal.IterableIterate

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public boolean
add(T element)

Implements java.util.Collection.add.

Ensures that this collection contains the specified element (optional operation).

public boolean
addAll(Collection<? extends T> source)

Implements java.util.Collection.addAll.

Adds all of the elements in the specified collection to this collection (optional operation).

public boolean
public RichIterable<RichIterable<T>>
chunk(int size)

Implements org.eclipse.collections.api.RichIterable.chunk.

Partitions elements in fixed size chunks.

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

Overrides default org.eclipse.collections.api.collection.MutableCollection.countBy, 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 <V> MutableBag<V>
countByEach(Function<? super T, ? extends Iterable<V>> function)

Overrides org.eclipse.collections.impl.AbstractRichIterable.countByEach.

Overrides default org.eclipse.collections.api.collection.MutableCollection.countByEach, 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 <V, P> MutableBag<V>
countByWith(Function2<? super T, ? super P, ? extends V> function, P parameter)

Overrides default org.eclipse.collections.api.collection.MutableCollection.countByWith, 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> MutableMap<V, T>
groupByUniqueKey(Function<? super T, ? extends V> function)

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

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)

Implements org.eclipse.collections.api.collection.MutableCollection.injectIntoWith.

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

public Optional<T>
reduce(BinaryOperator<T> accumulator)

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

This method produces the equivalent result as Stream#reduce(BinaryOperator).

public boolean
remove(Object o)

Implements java.util.Collection.remove.

Removes a single instance of the specified element from this collection, if it is present (optional operation).

public boolean
removeAll(Collection<?> source)

Implements java.util.Collection.removeAll.

Removes all of this collection's elements that are also contained in the specified collection (optional operation).

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

Implements org.eclipse.collections.api.collection.MutableCollection.removeIf.

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)

Implements org.eclipse.collections.api.collection.MutableCollection.removeIfWith.

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

public boolean
retainAll(Collection<?> source)

Implements java.util.Collection.retainAll.

Retains only the elements in this collection that are contained in the specified collection (optional operation).

public boolean
public <P> Twin<MutableList<T>>
selectAndRejectWith(Predicate2<? super T, ? super P> predicate, P parameter)

Implements org.eclipse.collections.api.collection.MutableCollection.selectAndRejectWith.

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

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

Implements org.eclipse.collections.api.collection.MutableCollection.sumByDouble, 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)

Implements org.eclipse.collections.api.collection.MutableCollection.sumByFloat, 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)

Implements org.eclipse.collections.api.collection.MutableCollection.sumByInt, 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)

Implements org.eclipse.collections.api.collection.MutableCollection.sumByLong, org.eclipse.collections.api.RichIterable.sumByLong.

Groups and sums the values using the two specified functions.

Inherited from org.eclipse.collections.impl.AbstractRichIterable:
allSatisfyallSatisfyWithanySatisfyanySatisfyWithappendStringappendStringasLazycollectcollectIfcollectWithcontainscontainsAllcontainsAllArgumentscontainsAllIterablecountcountWithdetectdetectOptionaldetectWithdetectWithIfNonedetectWithOptionalflatCollectforEachforEachWithforEachWithIndexgroupBygroupByEachgroupByUniqueKeyinjectIntoinjectIntoinjectIntoinjectIntoinjectIntointoisEmptymaxmaxmaxByminminminBynoneSatisfynoneSatisfyWithrejectrejectWithselectselectWithsumOfDoublesumOfFloatsumOfIntsumOfLongtoBagtoBiMaptoListtoMaptoSettoSortedBagtoSortedBagtoSortedBagBytoSortedListBytoSortedMaptoSortedMaptoSortedMapBytoSortedSettoSortedSettoSortedSetBytoStringzipzipWithIndex

Constructor Detail

AbstractMutableCollectionback to summary
public AbstractMutableCollection()

Method Detail

addback to summary
public boolean add(T element)

Implements java.util.Collection.add.

Doc from java.util.Collection.add.

Ensures that this collection contains the specified element (optional operation). Returns true if this collection changed as a result of the call. (Returns false if this collection does not permit duplicates and already contains the specified element.)

Collections that support this operation may place limitations on what elements may be added to this collection. In particular, some collections will refuse to add null elements, and others will impose restrictions on the type of elements that may be added. Collection classes should clearly specify in their documentation any restrictions on what elements may be added.

If a collection refuses to add a particular element for any reason other than that it already contains the element, it must throw an exception (rather than returning false). This preserves the invariant that a collection always contains the specified element after this call returns.

Annotations
@Override
addAllback to summary
public boolean addAll(Collection<? extends T> source)

Implements java.util.Collection.addAll.

Doc from java.util.Collection.addAll.

Adds all of the elements in the specified collection to this collection (optional operation). The behavior of this operation is undefined if the specified collection is modified while the operation is in progress. (This implies that the behavior of this call is undefined if the specified collection is this collection, and this collection is nonempty.) If the specified collection has a defined encounter order, processing of its elements generally occurs in that order.

Annotations
@Override
addAllIterableback to summary
public boolean addAllIterable(Iterable<? extends T> iterable)

Implements org.eclipse.collections.api.collection.MutableCollection.addAllIterable.

Annotations
@Override
chunkback to summary
public RichIterable<RichIterable<T>> chunk(int size)

Implements org.eclipse.collections.api.RichIterable.chunk.

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

Partitions elements in fixed size chunks.

Annotations
@Override
countByback to summary
public <V> MutableBag<V> countBy(Function<? super T, ? extends V> function)

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

Doc from 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.

Annotations
@Override
Since
9.0
countByEachback to summary
public <V> MutableBag<V> countByEach(Function<? super T, ? extends Iterable<V>> function)

Overrides org.eclipse.collections.impl.AbstractRichIterable.countByEach.

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

Doc from 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.

Annotations
@Override
Since
10.0.0
countByWithback to summary
public <V, P> MutableBag<V> countByWith(Function2<? super T, ? super P, ? extends V> function, P parameter)

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

Doc from 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.

Annotations
@Override
Since
9.0
groupByUniqueKeyback to summary
public <V> MutableMap<V, T> groupByUniqueKey(Function<? super T, ? extends V> function)

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

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

Doc from 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. The generated keys must each be unique, or else an exception is thrown.

Annotations
@Override
injectIntoWithback to summary
public <IV, P> IV injectIntoWith(IV injectValue, Function3<? super IV, ? super T, ? super P, ? extends IV> function, P parameter)

Implements org.eclipse.collections.api.collection.MutableCollection.injectIntoWith.

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

Returns the final result of evaluating function using each element of the iterable, the previous evaluation result and the parameters. The injected value is used for the first parameter of the first evaluation, and the current item in the iterable is used as the second parameter. The parameter value is always used as the third parameter to the function call.

Annotations
@Override
reduceback to summary
public Optional<T> reduce(BinaryOperator<T> accumulator)

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

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

This method produces the equivalent result as Stream#reduce(BinaryOperator).

Annotations
@Override
removeback to summary
public boolean remove(Object o)

Implements java.util.Collection.remove.

Doc from java.util.Collection.remove.

Removes a single instance of the specified element from this collection, if it is present (optional operation). More formally, removes an element e such that Objects.equals(o, e), if this collection contains one or more such elements. Returns true if this collection contained the specified element (or equivalently, if this collection changed as a result of the call).

Annotations
@Override
removeAllback to summary
public boolean removeAll(Collection<?> source)

Implements java.util.Collection.removeAll.

Doc from java.util.Collection.removeAll.

Removes all of this collection's elements that are also contained in the specified collection (optional operation). After this call returns, this collection will contain no elements in common with the specified collection.

Annotations
@Override
removeAllIterableback to summary
public boolean removeAllIterable(Iterable<?> iterable)

Implements org.eclipse.collections.api.collection.MutableCollection.removeAllIterable.

Annotations
@Override
removeIfback to summary
public boolean removeIf(Predicate<? super T> predicate)

Implements org.eclipse.collections.api.collection.MutableCollection.removeIf.

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

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

e.g.
return lastNames.removeIf(Predicates.isNull());
Annotations
@Override
removeIfWithback to summary
public <P> boolean removeIfWith(Predicate2<? super T, ? super P> predicate, P parameter)

Implements org.eclipse.collections.api.collection.MutableCollection.removeIfWith.

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

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

return lastNames.removeIfWith(Predicates2.isNull(), null);
Annotations
@Override
retainAllback to summary
public boolean retainAll(Collection<?> source)

Implements java.util.Collection.retainAll.

Doc from java.util.Collection.retainAll.

Retains only the elements in this collection that are contained in the specified collection (optional operation). In other words, removes from this collection all of its elements that are not contained in the specified collection.

Annotations
@Override
retainAllIterableback to summary
public boolean retainAllIterable(Iterable<?> iterable)

Implements org.eclipse.collections.api.collection.MutableCollection.retainAllIterable.

Annotations
@Override
selectAndRejectWithback to summary
public <P> Twin<MutableList<T>> selectAndRejectWith(Predicate2<? super T, ? super P> predicate, P parameter)

Implements org.eclipse.collections.api.collection.MutableCollection.selectAndRejectWith.

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

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

e.g.
return lastNames.selectAndRejectWith(Predicates2.lessThan(), "Mason");
Annotations
@Override
sumByDoubleback to summary
public <V> MutableObjectDoubleMap<V> sumByDouble(Function<? super T, ? extends V> groupBy, DoubleFunction<? super T> function)

Implements org.eclipse.collections.api.collection.MutableCollection.sumByDouble, org.eclipse.collections.api.RichIterable.sumByDouble.

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

Groups and sums the values using the two specified functions.

Annotations
@Override
sumByFloatback to summary
public <V> MutableObjectDoubleMap<V> sumByFloat(Function<? super T, ? extends V> groupBy, FloatFunction<? super T> function)

Implements org.eclipse.collections.api.collection.MutableCollection.sumByFloat, org.eclipse.collections.api.RichIterable.sumByFloat.

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

Groups and sums the values using the two specified functions.

Annotations
@Override
sumByIntback to summary
public <V> MutableObjectLongMap<V> sumByInt(Function<? super T, ? extends V> groupBy, IntFunction<? super T> function)

Implements org.eclipse.collections.api.collection.MutableCollection.sumByInt, org.eclipse.collections.api.RichIterable.sumByInt.

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

Groups and sums the values using the two specified functions.

Annotations
@Override
sumByLongback to summary
public <V> MutableObjectLongMap<V> sumByLong(Function<? super T, ? extends V> groupBy, LongFunction<? super T> function)

Implements org.eclipse.collections.api.collection.MutableCollection.sumByLong, org.eclipse.collections.api.RichIterable.sumByLong.

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

Groups and sums the values using the two specified functions.

Annotations
@Override