Class AbstractMutableCollection<T>
java.lang.Object
org.eclipse.collections.impl.AbstractRichIterable<T>
org.eclipse.collections.impl.collection.mutable.AbstractMutableCollection<T>
- All Implemented Interfaces:
Iterable<T>
,Collection<T>
,MutableCollection<T>
,InternalIterable<T>
,RichIterable<T>
- Direct Known Subclasses:
AbstractMutableList
,AbstractMutableSet
,AbstractUnifiedSet
,TreeSortedSet
public abstract class AbstractMutableCollection<T>
extends AbstractRichIterable<T>
implements MutableCollection<T>
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionboolean
boolean
addAll
(Collection<? extends T> source) boolean
addAllIterable
(Iterable<? extends T> iterable) chunk
(int size) Partitions elements in fixed size chunks.<V> MutableBag<V>
This method will count the number of occurrences of each value calculated by applying the function to each element of the collection.<V> MutableBag<V>
countByEach
(Function<? super T, ? extends Iterable<V>> function) This method will count the number of occurrences of each value calculated by applying the function to each element of the collection.<V,
P> MutableBag<V> countByWith
(Function2<? super T, ? super P, ? extends V> function, P parameter) 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.<V> MutableMap<V,
T> groupByUniqueKey
(Function<? super T, ? extends V> function) 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.<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.reduce
(BinaryOperator<T> accumulator) This method produces the equivalent result asStream.reduce(BinaryOperator)
.boolean
boolean
removeAll
(Collection<?> source) boolean
removeAllIterable
(Iterable<?> iterable) boolean
Removes all elements in the collection that evaluate to true for the specified predicate.<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.boolean
retainAll
(Collection<?> source) boolean
retainAllIterable
(Iterable<?> iterable) <P> Twin<MutableList<T>>
selectAndRejectWith
(Predicate2<? super T, ? super P> predicate, P parameter) Filters a collection into two separate collections based on a predicate returned via a Pair.<V> MutableObjectDoubleMap<V>
sumByDouble
(Function<? super T, ? extends V> groupBy, DoubleFunction<? super T> function) Groups and sums the values using the two specified functions.<V> MutableObjectDoubleMap<V>
sumByFloat
(Function<? super T, ? extends V> groupBy, FloatFunction<? super T> function) Groups and sums the values using the two specified functions.<V> MutableObjectLongMap<V>
sumByInt
(Function<? super T, ? extends V> groupBy, IntFunction<? super T> function) Groups and sums the values using the two specified functions.<V> MutableObjectLongMap<V>
sumByLong
(Function<? super T, ? extends V> groupBy, LongFunction<? super T> function) Groups and sums the values using the two specified functions.Methods inherited from class org.eclipse.collections.impl.AbstractRichIterable
allSatisfy, allSatisfyWith, anySatisfy, anySatisfyWith, appendString, appendString, asLazy, collect, collectIf, collectWith, contains, containsAll, containsAllArguments, containsAllIterable, count, countWith, detect, detectOptional, detectWith, detectWithIfNone, detectWithOptional, flatCollect, forEach, forEachWith, forEachWithIndex, groupBy, groupByEach, groupByUniqueKey, injectInto, injectInto, injectInto, injectInto, injectInto, into, isEmpty, max, max, maxBy, min, min, minBy, noneSatisfy, noneSatisfyWith, reject, rejectWith, select, selectWith, sumOfDouble, sumOfFloat, sumOfInt, sumOfLong, toArray, toArray, toBag, toBiMap, toList, toMap, toSet, toSortedBag, toSortedBag, toSortedBagBy, toSortedListBy, toSortedMap, toSortedMap, toSortedMapBy, toSortedSet, toSortedSet, toSortedSetBy, toString, zip, zipWithIndex
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.util.Collection
clear, contains, containsAll, equals, hashCode, isEmpty, iterator, parallelStream, removeIf, size, spliterator, stream, toArray, toArray, toArray
Methods inherited from interface org.eclipse.collections.api.InternalIterable
forEach, forEachWith, forEachWithIndex
Methods inherited from interface org.eclipse.collections.api.collection.MutableCollection
aggregateBy, aggregateInPlaceBy, asSynchronized, asUnmodifiable, collect, collectBoolean, collectByte, collectChar, collectDouble, collectFloat, collectIf, collectInt, collectLong, collectShort, collectWith, flatCollect, flatCollectWith, groupBy, groupByEach, newEmpty, partition, partitionWith, reject, rejectWith, select, selectInstancesOf, selectWith, tap, toImmutable, with, withAll, without, withoutAll, zip, zipWithIndex
Methods inherited from interface org.eclipse.collections.api.RichIterable
aggregateBy, allSatisfy, allSatisfyWith, anySatisfy, anySatisfyWith, appendString, appendString, appendString, asLazy, 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, reduceInPlace, reduceInPlace, reject, rejectWith, select, selectWith, size, summarizeDouble, summarizeFloat, summarizeInt, summarizeLong, sumOfDouble, sumOfFloat, sumOfInt, sumOfLong, toArray, toArray, toBag, toBiMap, toImmutableBag, 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
-
Constructor Details
-
AbstractMutableCollection
public AbstractMutableCollection()
-
-
Method Details
-
selectAndRejectWith
public <P> Twin<MutableList<T>> selectAndRejectWith(Predicate2<? super T, ? super P> predicate, P parameter) Description copied from interface:MutableCollection
Filters a collection into two separate collections based on a predicate returned via a Pair.e.g. return lastNames.selectAndRejectWith(Predicates2.lessThan(), "Mason");
- Specified by:
selectAndRejectWith
in interfaceMutableCollection<T>
-
removeIf
Description copied from interface:MutableCollection
Removes all elements in the collection that evaluate to true for the specified predicate.e.g. return lastNames.removeIf(Predicates.isNull());
- Specified by:
removeIf
in interfaceMutableCollection<T>
-
removeIfWith
Description copied from interface:MutableCollection
Removes all elements in the collection that evaluate to true for the specified predicate2 and parameter.return lastNames.removeIfWith(Predicates2.isNull(), null);
- Specified by:
removeIfWith
in interfaceMutableCollection<T>
-
injectIntoWith
public <IV,P> IV injectIntoWith(IV injectValue, Function3<? super IV, ? super T, ? super P, ? extends IV> function, P parameter) Description copied from interface:MutableCollection
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.- Specified by:
injectIntoWith
in interfaceMutableCollection<T>
- See Also:
-
reduce
Description copied from interface:RichIterable
This method produces the equivalent result asStream.reduce(BinaryOperator)
.- Specified by:
reduce
in interfaceRichIterable<T>
-
addAllIterable
- Specified by:
addAllIterable
in interfaceMutableCollection<T>
- See Also:
-
removeAllIterable
- Specified by:
removeAllIterable
in interfaceMutableCollection<T>
- See Also:
-
retainAllIterable
- Specified by:
retainAllIterable
in interfaceMutableCollection<T>
- See Also:
-
chunk
Description copied from interface:RichIterable
Partitions elements in fixed size chunks.- Specified by:
chunk
in interfaceRichIterable<T>
- Parameters:
size
- the number of elements per chunk- Returns:
- A
RichIterable
containingRichIterable
s of sizesize
, except the last will be truncated if the elements don't divide evenly.
-
sumByInt
public <V> MutableObjectLongMap<V> sumByInt(Function<? super T, ? extends V> groupBy, IntFunction<? super T> function) Description copied from interface:RichIterable
Groups and sums the values using the two specified functions.- Specified by:
sumByInt
in interfaceMutableCollection<T>
- Specified by:
sumByInt
in interfaceRichIterable<T>
-
sumByFloat
public <V> MutableObjectDoubleMap<V> sumByFloat(Function<? super T, ? extends V> groupBy, FloatFunction<? super T> function) Description copied from interface:RichIterable
Groups and sums the values using the two specified functions.- Specified by:
sumByFloat
in interfaceMutableCollection<T>
- Specified by:
sumByFloat
in interfaceRichIterable<T>
-
sumByLong
public <V> MutableObjectLongMap<V> sumByLong(Function<? super T, ? extends V> groupBy, LongFunction<? super T> function) Description copied from interface:RichIterable
Groups and sums the values using the two specified functions.- Specified by:
sumByLong
in interfaceMutableCollection<T>
- Specified by:
sumByLong
in interfaceRichIterable<T>
-
sumByDouble
public <V> MutableObjectDoubleMap<V> sumByDouble(Function<? super T, ? extends V> groupBy, DoubleFunction<? super T> function) Description copied from interface:RichIterable
Groups and sums the values using the two specified functions.- Specified by:
sumByDouble
in interfaceMutableCollection<T>
- Specified by:
sumByDouble
in interfaceRichIterable<T>
-
add
- Specified by:
add
in interfaceCollection<T>
-
remove
- Specified by:
remove
in interfaceCollection<T>
-
addAll
- Specified by:
addAll
in interfaceCollection<T>
-
removeAll
- Specified by:
removeAll
in interfaceCollection<T>
-
retainAll
- Specified by:
retainAll
in interfaceCollection<T>
-
groupByUniqueKey
Description copied from interface:RichIterable
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.- Specified by:
groupByUniqueKey
in interfaceMutableCollection<T>
- Specified by:
groupByUniqueKey
in interfaceRichIterable<T>
- See Also:
-
countBy
Description copied from interface:RichIterable
This method will count the number of occurrences of each value calculated by applying the function to each element of the collection.- Specified by:
countBy
in interfaceMutableCollection<T>
- Specified by:
countBy
in interfaceRichIterable<T>
- Since:
- 9.0
-
countByWith
public <V,P> MutableBag<V> countByWith(Function2<? super T, ? super P, ? extends V> function, P parameter) Description copied from interface:RichIterable
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.- Specified by:
countByWith
in interfaceMutableCollection<T>
- Specified by:
countByWith
in interfaceRichIterable<T>
- Since:
- 9.0
-
countByEach
Description copied from interface:RichIterable
This method will count the number of occurrences of each value calculated by applying the function to each element of the collection.- Specified by:
countByEach
in interfaceMutableCollection<T>
- Specified by:
countByEach
in interfaceRichIterable<T>
- Overrides:
countByEach
in classAbstractRichIterable<T>
- Since:
- 10.0.0
-