java.lang.Iterable<T>, java.util.Collection<T>, Bag<T>, MutableBagIterable<T>, MutableCollection<T>, InternalIterable<T>, RichIterable<T>AbstractMutableBag, AbstractMutableSortedBagpublic abstract class AbstractMutableBagIterable<T> extends AbstractBag<T> implements MutableBagIterable<T>
| Constructor | Description |
|---|---|
AbstractMutableBagIterable() |
| Modifier and Type | Method | Description |
|---|---|---|
boolean |
addAll(java.util.Collection<? extends T> source) |
|
boolean |
addAllIterable(java.lang.Iterable<? extends T> iterable) |
|
<K,V> MutableMap<K,V> |
aggregateBy(Function<? super T,? extends K> groupBy,
Function0<? extends V> zeroValueFactory,
Function2<? super V,? super T,? extends V> nonMutatingAggregator) |
Applies an aggregate function over the iterable grouping results into a map based on the specific groupBy function.
|
<K,V> MutableMap<K,V> |
aggregateInPlaceBy(Function<? super T,? extends K> groupBy,
Function0<? extends V> zeroValueFactory,
Procedure2<? super V,? super T> mutatingAggregator) |
Applies an aggregate procedure over the iterable grouping results into a Map based on the specific groupBy function.
|
boolean |
allSatisfy(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> boolean |
allSatisfyWith(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.
|
boolean |
anySatisfy(Predicate<? super T> predicate) |
Returns true if the predicate evaluates to true for any element of the iterable.
|
<P> boolean |
anySatisfyWith(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.
|
MutableList<ObjectIntPair<T>> |
bottomOccurrences(int n) |
Returns the
count least frequently occurring items. |
RichIterable<RichIterable<T>> |
chunk(int size) |
Partitions elements in fixed size chunks.
|
<V> MutableBag<V> |
countBy(Function<? super T,? extends 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> MutableBag<V> |
countByEach(Function<? super T,? extends java.lang.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.
|
T |
detect(Predicate<? super T> predicate) |
Returns the first element of the iterable for which the predicate evaluates to true or null in the case where no
element returns true.
|
T |
detectIfNone(Predicate<? super T> predicate,
Function0<? extends T> function) |
Returns the first element of the iterable for which the predicate evaluates to true.
|
java.util.Optional<T> |
detectOptional(Predicate<? super T> predicate) |
Returns the first element of the iterable for which the predicate evaluates to true as an Optional.
|
<P> T |
detectWith(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> T |
detectWithIfNone(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.
|
<P> java.util.Optional<T> |
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.
|
T |
getFirst() |
Returns the first element of an iterable.
|
T |
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 he results of these evaluations are collected
into a new map, where the transformed value is the key.
|
T |
max() |
Returns the maximum element out of this container based on the natural order.
|
T |
max(java.util.Comparator<? super T> comparator) |
Returns the maximum element out of this container based on the comparator.
|
<V extends java.lang.Comparable<? super V>> |
maxBy(Function<? super T,? extends V> function) |
Returns the maximum elements out of this container based on the natural order of the attribute returned by Function.
|
T |
min() |
Returns the minimum element out of this container based on the natural order.
|
T |
min(java.util.Comparator<? super T> comparator) |
Returns the minimum element out of this container based on the comparator.
|
<V extends java.lang.Comparable<? super V>> |
minBy(Function<? super T,? extends V> function) |
Returns the minimum elements out of this container based on the natural order of the attribute returned by Function.
|
boolean |
noneSatisfy(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> boolean |
noneSatisfyWith(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.
|
boolean |
removeAll(java.util.Collection<?> collection) |
|
boolean |
retainAll(java.util.Collection<?> collection) |
|
boolean |
retainAllIterable(java.lang.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.
|
MutableList<ObjectIntPair<T>> |
topOccurrences(int n) |
Returns the
count most frequently occurring items. |
collect, collectBoolean, collectByte, collectChar, collectDouble, collectFloat, collectIf, collectInt, collectLong, collectShort, collectWith, count, flatCollect, groupBy, groupByEach, injectInto, injectInto, injectInto, injectInto, injectInto, injectIntoWith, reject, rejectWith, select, selectWith, sumOfDouble, sumOfFloat, sumOfInt, sumOfLong, toBag, toList, toSet, toSortedBag, toSortedBag, toSortedList, toSortedSet, toSortedSet, toStringOfItemToCountappendString, 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, zipWithIndexcollectWithOccurrences, equals, forEachWithOccurrences, hashCode, occurrencesOf, reduceInPlace, reduceInPlace, sizeDistinct, summarizeDouble, summarizeFloat, summarizeInt, summarizeLong, toImmutable, toStringOfItemToCountadd, clear, contains, containsAll, equals, hashCode, isEmpty, iterator, parallelStream, remove, removeIf, size, spliterator, stream, toArray, toArrayforEach, forEachWith, forEachWithIndexaddOccurrences, collectWithOccurrences, groupBy, groupByEach, partition, partitionWith, reject, rejectWith, removeOccurrences, select, selectByOccurrences, selectDuplicates, selectInstancesOf, selectUnique, selectWith, setOccurrences, tap, toMapOfItemToCount, with, withAll, without, withoutAll, zipWithIndexasSynchronized, asUnmodifiable, collect, collectBoolean, collectByte, collectChar, collectDouble, collectFloat, collectIf, collectInt, collectLong, collectShort, collectWith, flatCollect, flatCollectWith, injectIntoWith, newEmpty, removeAllIterable, removeIf, removeIfWith, toImmutable, zipequals, getClass, hashCode, notify, notifyAll, wait, wait, waitappendString, appendString, appendString, asLazy, collect, collectBoolean, collectByte, collectChar, collectDouble, collectFloat, collectIf, collectInt, collectLong, collectShort, collectWith, contains, containsAll, containsAllArguments, containsAllIterable, count, countBy, countByEach, countByWith, countWith, each, flatCollect, flatCollectWith, forEach, getAny, getOnly, groupBy, groupByAndCollect, groupByEach, groupByUniqueKey, injectInto, injectInto, injectInto, injectInto, injectInto, into, isEmpty, makeString, makeString, makeString, maxByOptional, maxOptional, maxOptional, minByOptional, minOptional, minOptional, notEmpty, reduce, reject, rejectWith, select, selectWith, size, sumOfDouble, sumOfFloat, sumOfInt, sumOfLong, toArray, toArray, toBag, toBiMap, toList, toMap, toMap, toSet, toSortedBag, toSortedBag, toSortedBagBy, toSortedList, toSortedList, toSortedListBy, toSortedMap, toSortedMap, toSortedMapBy, toSortedSet, toSortedSet, toSortedSetBy, toString, zip, zipWithIndexpublic boolean addAll(java.util.Collection<? extends T> source)
addAll in interface java.util.Collection<T>public boolean addAllIterable(java.lang.Iterable<? extends T> iterable)
addAllIterable in interface MutableCollection<T>Collection.addAll(Collection)public boolean removeAll(java.util.Collection<?> collection)
removeAll in interface java.util.Collection<T>public boolean retainAll(java.util.Collection<?> collection)
retainAll in interface java.util.Collection<T>public boolean retainAllIterable(java.lang.Iterable<?> iterable)
retainAllIterable in interface MutableCollection<T>Collection.retainAll(Collection)public <P> Twin<MutableList<T>> selectAndRejectWith(Predicate2<? super T,? super P> predicate, P parameter)
MutableCollection
e.g. return lastNames.selectAndRejectWith(Predicates2.lessThan(), "Mason");
selectAndRejectWith in interface MutableCollection<T>public T getFirst()
RichIterableThe 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.
getFirst in interface RichIterable<T>public T getLast()
RichIterableThe 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.
getLast in interface RichIterable<T>public <V> MutableMap<V,T> groupByUniqueKey(Function<? super T,? extends V> function)
RichIterablegroupByUniqueKey in interface MutableCollection<T>groupByUniqueKey in interface RichIterable<T>RichIterable.groupBy(Function)public RichIterable<RichIterable<T>> chunk(int size)
RichIterablechunk in interface RichIterable<T>size - the number of elements per chunkRichIterable containing RichIterables of size size, except the last will be
truncated if the elements don't divide evenly.public T detect(Predicate<? super T> predicate)
RichIterableExample 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");
}
});
detect in interface RichIterable<T>detect in class AbstractRichIterable<T>public <P> T detectWith(Predicate2<? super T,? super P> predicate, P parameter)
RichIterableExample 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");
detectWith in interface RichIterable<T>detectWith in class AbstractRichIterable<T>public java.util.Optional<T> detectOptional(Predicate<? super T> predicate)
RichIterableExample using a Java 8 lambda expression:
Person person =
people.detectOptional(person -> person.getFirstName().equals("John") && person.getLastName().equals("Smith"));
detectOptional in interface RichIterable<T>detectOptional in class AbstractRichIterable<T>public <P> java.util.Optional<T> detectWithOptional(Predicate2<? super T,? super P> predicate, P parameter)
RichIterableExample using a Java 8 lambda expression:
Optional<Person> person =
people.detectWithOptional((person, fullName) -> person.getFullName().equals(fullName), "John Smith");
detectWithOptional in interface RichIterable<T>detectWithOptional in class AbstractRichIterable<T>public T detectIfNone(Predicate<? super T> predicate, Function0<? extends T> function)
RichIterabledetectIfNone in interface RichIterable<T>public <P> T detectWithIfNone(Predicate2<? super T,? super P> predicate, P parameter, Function0<? extends T> function)
RichIterabledetectWithIfNone in interface RichIterable<T>detectWithIfNone in class AbstractRichIterable<T>public boolean anySatisfy(Predicate<? super T> predicate)
RichIterableanySatisfy in interface RichIterable<T>anySatisfy in class AbstractRichIterable<T>public <P> boolean anySatisfyWith(Predicate2<? super T,? super P> predicate, P parameter)
RichIterableanySatisfyWith in interface RichIterable<T>anySatisfyWith in class AbstractRichIterable<T>public boolean allSatisfy(Predicate<? super T> predicate)
RichIterableallSatisfy in interface RichIterable<T>allSatisfy in class AbstractRichIterable<T>public <P> boolean allSatisfyWith(Predicate2<? super T,? super P> predicate, P parameter)
RichIterableallSatisfyWith in interface RichIterable<T>allSatisfyWith in class AbstractRichIterable<T>public boolean noneSatisfy(Predicate<? super T> predicate)
RichIterablenoneSatisfy in interface RichIterable<T>noneSatisfy in class AbstractRichIterable<T>public <P> boolean noneSatisfyWith(Predicate2<? super T,? super P> predicate, P parameter)
RichIterablenoneSatisfyWith in interface RichIterable<T>noneSatisfyWith in class AbstractRichIterable<T>public <V> MutableBag<V> countBy(Function<? super T,? extends V> function)
RichIterablecountBy in interface MutableCollection<T>countBy in interface RichIterable<T>public <V,P> MutableBag<V> countByWith(Function2<? super T,? super P,? extends V> function, P parameter)
RichIterablecountByWith in interface MutableCollection<T>countByWith in interface RichIterable<T>public <V> MutableBag<V> countByEach(Function<? super T,? extends java.lang.Iterable<V>> function)
RichIterablecountByEach in interface MutableCollection<T>countByEach in interface RichIterable<T>countByEach in class AbstractRichIterable<T>public T min()
RichIterablemin in interface RichIterable<T>min in class AbstractRichIterable<T>public T min(java.util.Comparator<? super T> comparator)
RichIterablemin in interface RichIterable<T>min in class AbstractRichIterable<T>public <V extends java.lang.Comparable<? super V>> T minBy(Function<? super T,? extends V> function)
RichIterableminBy in interface RichIterable<T>minBy in class AbstractRichIterable<T>public T max()
RichIterablemax in interface RichIterable<T>max in class AbstractRichIterable<T>public T max(java.util.Comparator<? super T> comparator)
RichIterablemax in interface RichIterable<T>max in class AbstractRichIterable<T>public <V extends java.lang.Comparable<? super V>> T maxBy(Function<? super T,? extends V> function)
RichIterablemaxBy in interface RichIterable<T>maxBy in class AbstractRichIterable<T>public <K,V> MutableMap<K,V> aggregateInPlaceBy(Function<? super T,? extends K> groupBy, Function0<? extends V> zeroValueFactory, Procedure2<? super V,? super T> mutatingAggregator)
RichIterableaggregateInPlaceBy in interface MutableCollection<T>aggregateInPlaceBy in interface RichIterable<T>public <K,V> MutableMap<K,V> aggregateBy(Function<? super T,? extends K> groupBy, Function0<? extends V> zeroValueFactory, Function2<? super V,? super T,? extends V> nonMutatingAggregator)
RichIterableaggregateBy in interface MutableCollection<T>aggregateBy in interface RichIterable<T>public <V> MutableObjectLongMap<V> sumByInt(Function<? super T,? extends V> groupBy, IntFunction<? super T> function)
RichIterablesumByInt in interface MutableCollection<T>sumByInt in interface RichIterable<T>public <V> MutableObjectDoubleMap<V> sumByFloat(Function<? super T,? extends V> groupBy, FloatFunction<? super T> function)
RichIterablesumByFloat in interface MutableCollection<T>sumByFloat in interface RichIterable<T>public <V> MutableObjectLongMap<V> sumByLong(Function<? super T,? extends V> groupBy, LongFunction<? super T> function)
RichIterablesumByLong in interface MutableCollection<T>sumByLong in interface RichIterable<T>public <V> MutableObjectDoubleMap<V> sumByDouble(Function<? super T,? extends V> groupBy, DoubleFunction<? super T> function)
RichIterablesumByDouble in interface MutableCollection<T>sumByDouble in interface RichIterable<T>public MutableList<ObjectIntPair<T>> topOccurrences(int n)
Bagcount most 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.topOccurrences in interface Bag<T>topOccurrences in interface MutableBagIterable<T>public MutableList<ObjectIntPair<T>> bottomOccurrences(int n)
Bagcount least 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.bottomOccurrences in interface Bag<T>bottomOccurrences in interface MutableBagIterable<T>Copyright © 2004–2020. All rights reserved.