Class AbstractMutableBagIterable<T>
java.lang.Object
org.eclipse.collections.impl.AbstractRichIterable<T>
org.eclipse.collections.impl.bag.AbstractBag<T>
org.eclipse.collections.impl.bag.mutable.AbstractMutableBagIterable<T>
- All Implemented Interfaces:
Iterable<T>,Collection<T>,Bag<T>,MutableBagIterable<T>,MutableCollection<T>,InternalIterable<T>,RichIterable<T>
- Direct Known Subclasses:
AbstractMutableBag,AbstractMutableSortedBag
public abstract class AbstractMutableBagIterable<T>
extends AbstractBag<T>
implements MutableBagIterable<T>
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanaddAll(Collection<? extends T> source) booleanaddAllIterable(Iterable<? extends T> iterable) booleanallSatisfy(Predicate<? super T> predicate) Returns true if the predicate evaluates to true for every element of the iterable or if the iterable is empty.<P> booleanallSatisfyWith(Predicate2<? super T, ? super P> predicate, P parameter) Returns true if the predicate evaluates to true for every element of the collection, or returns false.booleananySatisfy(Predicate<? super T> predicate) Returns true if the predicate evaluates to true for any element of the iterable.<P> booleananySatisfyWith(Predicate2<? super T, ? super P> predicate, P parameter) Returns true if the predicate evaluates to true for any element of the collection, or return false.bottomOccurrences(int n) Returns thecountleast frequently occurring items.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.Returns the first element of the iterable for which the predicate evaluates to true or null in the case where no element returns true.detectIfNone(Predicate<? super T> predicate, Function0<? extends T> function) Returns the first element of the iterable for which the predicate evaluates to true.detectOptional(Predicate<? super T> predicate) Returns the first element of the iterable for which the predicate evaluates to true as an Optional.<P> TdetectWith(Predicate2<? super T, ? super P> predicate, P parameter) Returns the first element that evaluates to true for the specified predicate2 and parameter, or null if none evaluate to true.<P> TdetectWithIfNone(Predicate2<? super T, ? super P> predicate, P parameter, Function0<? extends T> function) Returns the first element of the iterable that evaluates to true for the specified predicate2 and parameter, or returns the value of evaluating the specified function.detectWithOptional(Predicate2<? super T, ? super P> predicate, P parameter) Returns the first element that evaluates to true for the specified predicate2 and parameter as an Optional.getFirst()Returns the first element of an iterable.getLast()Returns the last element of an iterable.<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.max()Returns the maximum element out of this container based on the natural order.max(Comparator<? super T> comparator) Returns the maximum element out of this container based on the comparator.<V extends Comparable<? super V>>
TReturns the maximum elements out of this container based on the natural order of the attribute returned by Function.min()Returns the minimum element out of this container based on the natural order.min(Comparator<? super T> comparator) Returns the minimum element out of this container based on the comparator.<V extends Comparable<? super V>>
TReturns the minimum elements out of this container based on the natural order of the attribute returned by Function.booleannoneSatisfy(Predicate<? super T> predicate) Returns true if the predicate evaluates to false for every element of the iterable or if the iterable is empty.<P> booleannoneSatisfyWith(Predicate2<? super T, ? super P> predicate, P parameter) Returns true if the predicate evaluates to false for every element of the collection, or return false.booleanremoveAll(Collection<?> collection) booleanretainAll(Collection<?> collection) booleanretainAllIterable(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.topOccurrences(int n) Returns thecountmost frequently occurring items.Methods inherited from class org.eclipse.collections.impl.bag.AbstractBag
collect, collectBoolean, collectByte, collectChar, collectDouble, collectFloat, collectIf, collectInt, collectLong, collectShort, collectWith, count, flatCollect, flatCollectBoolean, flatCollectByte, flatCollectChar, flatCollectDouble, flatCollectFloat, flatCollectInt, flatCollectLong, flatCollectShort, groupBy, groupByEach, injectInto, injectInto, injectInto, injectInto, injectInto, injectIntoWith, reject, rejectWith, select, selectWith, sumOfDouble, sumOfFloat, sumOfInt, sumOfLong, toBag, toList, toSet, toSortedBag, toSortedBag, toSortedList, toSortedSet, toSortedSet, toStringOfItemToCountMethods inherited from class org.eclipse.collections.impl.AbstractRichIterable
appendString, appendString, asLazy, contains, containsAll, containsAllArguments, containsAllIterable, countWith, forEach, forEachWith, forEachWithIndex, groupByUniqueKey, into, isEmpty, toArray, toArray, toBiMap, toMap, toSortedBagBy, toSortedListBy, toSortedMap, toSortedMap, toSortedMapBy, toSortedSetBy, toString, zip, zipWithIndexMethods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.eclipse.collections.api.bag.Bag
aggregateBy, allSatisfyWithOccurrences, anySatisfyWithOccurrences, collectWithOccurrences, detectWithOccurrences, distinctView, equals, forEachWithOccurrences, hashCode, noneSatisfyWithOccurrences, occurrencesOf, reduceInPlace, reduceInPlace, sizeDistinct, summarizeDouble, summarizeFloat, summarizeInt, summarizeLong, toImmutable, toStringOfItemToCountMethods inherited from interface java.util.Collection
add, clear, contains, containsAll, equals, hashCode, isEmpty, iterator, parallelStream, remove, removeIf, size, spliterator, stream, toArray, toArray, toArrayMethods inherited from interface org.eclipse.collections.api.InternalIterable
forEach, forEachWith, forEachWithIndexMethods inherited from interface org.eclipse.collections.api.bag.MutableBagIterable
addOccurrences, collectWithOccurrences, groupBy, groupByEach, partition, partitionWith, reject, rejectWith, removeOccurrences, select, selectByOccurrences, selectDuplicates, selectInstancesOf, selectUnique, selectWith, setOccurrences, tap, toMapOfItemToCount, with, withAll, without, withoutAll, zipWithIndexMethods 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, injectIntoWith, newEmpty, removeAllIterable, removeIf, removeIfWith, toImmutable, zipMethods inherited from interface org.eclipse.collections.api.RichIterable
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, each, flatCollect, flatCollectBoolean, flatCollectByte, flatCollectChar, flatCollectDouble, flatCollectFloat, flatCollectInt, flatCollectLong, flatCollectShort, flatCollectWith, forEach, getAny, getOnly, groupBy, groupByAndCollect, groupByEach, groupByUniqueKey, injectInto, injectInto, injectInto, injectInto, injectInto, injectIntoDouble, injectIntoFloat, injectIntoInt, injectIntoLong, into, isEmpty, makeString, makeString, makeString, makeString, maxByOptional, maxOptional, maxOptional, minByOptional, minOptional, minOptional, notEmpty, reduce, reject, rejectWith, select, selectWith, size, 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
-
AbstractMutableBagIterable
public AbstractMutableBagIterable()
-
-
Method Details
-
addAll
- Specified by:
addAllin interfaceCollection<T>
-
addAllIterable
- Specified by:
addAllIterablein interfaceMutableCollection<T>- See Also:
-
removeAll
- Specified by:
removeAllin interfaceCollection<T>
-
retainAll
- Specified by:
retainAllin interfaceCollection<T>
-
retainAllIterable
- Specified by:
retainAllIterablein interfaceMutableCollection<T>- See Also:
-
selectAndRejectWith
public <P> Twin<MutableList<T>> selectAndRejectWith(Predicate2<? super T, ? super P> predicate, P parameter) Description copied from interface:MutableCollectionFilters a collection into two separate collections based on a predicate returned via a Pair.e.g. return lastNames.selectAndRejectWith(Predicates2.lessThan(), "Mason");
- Specified by:
selectAndRejectWithin interfaceMutableCollection<T>
-
getFirst
Description copied from interface:RichIterableReturns the first element of an iterable. In the case of a List it is the element at the first index. In the case of any other Collection, it is the first element that would be returned during an iteration. If the iterable is empty, null is returned. If null is a valid element of the container, then a developer would need to check to see if the iterable is empty to validate that a null result was not due to the container being empty.The order of Sets are not guaranteed (except for TreeSets and other Ordered Set implementations), so if you use this method, the first element could be any element from the Set.
- Specified by:
getFirstin interfaceRichIterable<T>
-
getLast
Description copied from interface:RichIterableReturns the last element of an iterable. In the case of a List it is the element at the last index. In the case of any other Collection, it is the last element that would be returned during an iteration. If the iterable is empty, null is returned. If null is a valid element of the container, then a developer would need to check to see if the iterable is empty to validate that a null result was not due to the container being empty.The order of Sets are not guaranteed (except for TreeSets and other Ordered Set implementations), so if you use this method, the last element could be any element from the Set.
- Specified by:
getLastin interfaceRichIterable<T>
-
groupByUniqueKey
Description copied from interface:RichIterableFor 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:
groupByUniqueKeyin interfaceMutableCollection<T>- Specified by:
groupByUniqueKeyin interfaceRichIterable<T>- See Also:
-
chunk
Description copied from interface:RichIterablePartitions elements in fixed size chunks.- Specified by:
chunkin interfaceRichIterable<T>- Parameters:
size- the number of elements per chunk- Returns:
- A
RichIterablecontainingRichIterables of sizesize, except the last will be truncated if the elements don't divide evenly.
-
detect
Description copied from interface:RichIterableReturns the first element of the iterable for which the predicate evaluates to true or null in the case where no element returns true. This method is commonly called find.Example using a Java 8 lambda expression:
Person person = people.detect(person -> person.getFirstName().equals("John") && person.getLastName().equals("Smith"));Example using an anonymous inner class:
Person person = people.detect(new Predicate<Person>() { public boolean accept(Person person) { return person.getFirstName().equals("John") && person.getLastName().equals("Smith"); } });- Specified by:
detectin interfaceRichIterable<T>- Overrides:
detectin classAbstractRichIterable<T>
-
detectWith
Description copied from interface:RichIterableReturns the first element that evaluates to true for the specified predicate2 and parameter, or null if none evaluate to true.Example using a Java 8 lambda expression:
Person person = people.detectWith((person, fullName) -> person.getFullName().equals(fullName), "John Smith");Example using an anonymous inner class:
Person person = people.detectWith(new Predicate2<Person, String>() { public boolean accept(Person person, String fullName) { return person.getFullName().equals(fullName); } }, "John Smith");- Specified by:
detectWithin interfaceRichIterable<T>- Overrides:
detectWithin classAbstractRichIterable<T>
-
detectOptional
Description copied from interface:RichIterableReturns the first element of the iterable for which the predicate evaluates to true as an Optional. This method is commonly called find.Example using a Java 8 lambda expression:
Person person = people.detectOptional(person -> person.getFirstName().equals("John") && person.getLastName().equals("Smith"));- Specified by:
detectOptionalin interfaceRichIterable<T>- Overrides:
detectOptionalin classAbstractRichIterable<T>
-
detectWithOptional
Description copied from interface:RichIterableReturns the first element that evaluates to true for the specified predicate2 and parameter as an Optional.Example using a Java 8 lambda expression:
Optional<Person> person = people.detectWithOptional((person, fullName) -> person.getFullName().equals(fullName), "John Smith");- Specified by:
detectWithOptionalin interfaceRichIterable<T>- Overrides:
detectWithOptionalin classAbstractRichIterable<T>
-
detectIfNone
Description copied from interface:RichIterableReturns the first element of the iterable for which the predicate evaluates to true. If no element matches the predicate, then returns the value of applying the specified function.- Specified by:
detectIfNonein interfaceRichIterable<T>
-
detectWithIfNone
public <P> T detectWithIfNone(Predicate2<? super T, ? super P> predicate, P parameter, Function0<? extends T> function) Description copied from interface:RichIterableReturns the first element of the iterable that evaluates to true for the specified predicate2 and parameter, or returns the value of evaluating the specified function.- Specified by:
detectWithIfNonein interfaceRichIterable<T>- Overrides:
detectWithIfNonein classAbstractRichIterable<T>
-
anySatisfy
Description copied from interface:RichIterableReturns true if the predicate evaluates to true for any element of the iterable. Returns false if the iterable is empty, or if no element returned true when evaluating the predicate.- Specified by:
anySatisfyin interfaceRichIterable<T>- Overrides:
anySatisfyin classAbstractRichIterable<T>
-
anySatisfyWith
Description copied from interface:RichIterableReturns true if the predicate evaluates to true for any element of the collection, or return false. Returns false if the collection is empty.- Specified by:
anySatisfyWithin interfaceRichIterable<T>- Overrides:
anySatisfyWithin classAbstractRichIterable<T>
-
allSatisfy
Description copied from interface:RichIterableReturns true if the predicate evaluates to true for every element of the iterable or if the iterable is empty. Otherwise, returns false.- Specified by:
allSatisfyin interfaceRichIterable<T>- Overrides:
allSatisfyin classAbstractRichIterable<T>
-
allSatisfyWith
Description copied from interface:RichIterableReturns true if the predicate evaluates to true for every element of the collection, or returns false.- Specified by:
allSatisfyWithin interfaceRichIterable<T>- Overrides:
allSatisfyWithin classAbstractRichIterable<T>
-
noneSatisfy
Description copied from interface:RichIterableReturns true if the predicate evaluates to false for every element of the iterable or if the iterable is empty. Otherwise, returns false.- Specified by:
noneSatisfyin interfaceRichIterable<T>- Overrides:
noneSatisfyin classAbstractRichIterable<T>
-
noneSatisfyWith
Description copied from interface:RichIterableReturns true if the predicate evaluates to false for every element of the collection, or return false. Returns true if the collection is empty.- Specified by:
noneSatisfyWithin interfaceRichIterable<T>- Overrides:
noneSatisfyWithin classAbstractRichIterable<T>
-
countBy
Description copied from interface:RichIterableThis method will count the number of occurrences of each value calculated by applying the function to each element of the collection.- Specified by:
countByin interfaceMutableCollection<T>- Specified by:
countByin 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:RichIterableThis 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:
countByWithin interfaceMutableCollection<T>- Specified by:
countByWithin interfaceRichIterable<T>- Since:
- 9.0
-
countByEach
Description copied from interface:RichIterableThis method will count the number of occurrences of each value calculated by applying the function to each element of the collection.- Specified by:
countByEachin interfaceMutableCollection<T>- Specified by:
countByEachin interfaceRichIterable<T>- Overrides:
countByEachin classAbstractRichIterable<T>- Since:
- 10.0.0
-
min
Description copied from interface:RichIterableReturns the minimum element out of this container based on the natural order.- Specified by:
minin interfaceRichIterable<T>- Overrides:
minin classAbstractRichIterable<T>
-
min
Description copied from interface:RichIterableReturns the minimum element out of this container based on the comparator.- Specified by:
minin interfaceRichIterable<T>- Overrides:
minin classAbstractRichIterable<T>
-
minBy
Description copied from interface:RichIterableReturns the minimum elements out of this container based on the natural order of the attribute returned by Function.- Specified by:
minByin interfaceRichIterable<T>- Overrides:
minByin classAbstractRichIterable<T>
-
max
Description copied from interface:RichIterableReturns the maximum element out of this container based on the natural order.- Specified by:
maxin interfaceRichIterable<T>- Overrides:
maxin classAbstractRichIterable<T>
-
max
Description copied from interface:RichIterableReturns the maximum element out of this container based on the comparator.- Specified by:
maxin interfaceRichIterable<T>- Overrides:
maxin classAbstractRichIterable<T>
-
maxBy
Description copied from interface:RichIterableReturns the maximum elements out of this container based on the natural order of the attribute returned by Function.- Specified by:
maxByin interfaceRichIterable<T>- Overrides:
maxByin classAbstractRichIterable<T>
-
sumByInt
public <V> MutableObjectLongMap<V> sumByInt(Function<? super T, ? extends V> groupBy, IntFunction<? super T> function) Description copied from interface:RichIterableGroups and sums the values using the two specified functions.- Specified by:
sumByIntin interfaceMutableCollection<T>- Specified by:
sumByIntin interfaceRichIterable<T>
-
sumByFloat
public <V> MutableObjectDoubleMap<V> sumByFloat(Function<? super T, ? extends V> groupBy, FloatFunction<? super T> function) Description copied from interface:RichIterableGroups and sums the values using the two specified functions.- Specified by:
sumByFloatin interfaceMutableCollection<T>- Specified by:
sumByFloatin interfaceRichIterable<T>
-
sumByLong
public <V> MutableObjectLongMap<V> sumByLong(Function<? super T, ? extends V> groupBy, LongFunction<? super T> function) Description copied from interface:RichIterableGroups and sums the values using the two specified functions.- Specified by:
sumByLongin interfaceMutableCollection<T>- Specified by:
sumByLongin interfaceRichIterable<T>
-
sumByDouble
public <V> MutableObjectDoubleMap<V> sumByDouble(Function<? super T, ? extends V> groupBy, DoubleFunction<? super T> function) Description copied from interface:RichIterableGroups and sums the values using the two specified functions.- Specified by:
sumByDoublein interfaceMutableCollection<T>- Specified by:
sumByDoublein interfaceRichIterable<T>
-
topOccurrences
Description copied from interface:BagReturns thecountmost frequently occurring items. In the event of a tie, all the items with the number of occurrences that match the occurrences of the last item will be returned.- Specified by:
topOccurrencesin interfaceBag<T>- Specified by:
topOccurrencesin interfaceMutableBagIterable<T>
-
bottomOccurrences
Description copied from interface:BagReturns thecountleast frequently occurring items. In the event of a tie, all of the items with the number of occurrences that match the occurrences of the last item will be returned.- Specified by:
bottomOccurrencesin interfaceBag<T>- Specified by:
bottomOccurrencesin interfaceMutableBagIterable<T>
-