Iterable<T>
, Collection<T>
, Bag<T>
, MutableBagIterable<T>
, MutableCollection<T>
, InternalIterable<T>
, RichIterable<T>
AbstractMutableBag
, AbstractMutableSortedBag
public abstract class AbstractMutableBagIterable<T> extends AbstractBag<T> implements MutableBagIterable<T>
Constructor | Description |
---|---|
AbstractMutableBagIterable() |
Modifier and Type | Method | Description |
---|---|---|
boolean |
addAll(Collection<? extends T> source) |
|
boolean |
addAllIterable(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 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.
|
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> 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(Comparator<? super T> comparator) |
Returns the maximum element out of this container based on the comparator.
|
<V extends 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(Comparator<? super T> comparator) |
Returns the minimum element out of this container based on the comparator.
|
<V extends 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(Collection<?> collection) |
|
boolean |
retainAll(Collection<?> collection) |
|
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.
|
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, toStringOfItemToCount
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, zipWithIndex
collectWithOccurrences, equals, forEachWithOccurrences, hashCode, occurrencesOf, reduceInPlace, reduceInPlace, sizeDistinct, summarizeDouble, summarizeFloat, summarizeInt, summarizeLong, toImmutable, toStringOfItemToCount
add, clear, contains, containsAll, equals, hashCode, isEmpty, iterator, parallelStream, remove, removeIf, size, spliterator, stream, toArray, toArray
forEach, forEachWith, forEachWithIndex
addOccurrences, collectWithOccurrences, groupBy, groupByEach, partition, partitionWith, reject, rejectWith, removeOccurrences, select, selectByOccurrences, selectDuplicates, selectInstancesOf, selectUnique, selectWith, setOccurrences, tap, toMapOfItemToCount, with, withAll, without, withoutAll, zipWithIndex
asSynchronized, asUnmodifiable, collect, collectBoolean, collectByte, collectChar, collectDouble, collectFloat, collectIf, collectInt, collectLong, collectShort, collectWith, flatCollect, flatCollectWith, injectIntoWith, newEmpty, removeAllIterable, removeIf, removeIfWith, toImmutable, zip
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
appendString, 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, 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, zipWithIndex
public boolean addAll(Collection<? extends T> source)
addAll
in interface Collection<T>
public boolean addAllIterable(Iterable<? extends T> iterable)
addAllIterable
in interface MutableCollection<T>
Collection.addAll(Collection)
public boolean removeAll(Collection<?> collection)
removeAll
in interface Collection<T>
public boolean retainAll(Collection<?> collection)
retainAll
in interface Collection<T>
public boolean retainAllIterable(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()
RichIterable
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.
getFirst
in interface RichIterable<T>
public T getLast()
RichIterable
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.
getLast
in interface RichIterable<T>
public <V> MutableMap<V,T> groupByUniqueKey(Function<? super T,? extends V> function)
RichIterable
groupByUniqueKey
in interface MutableCollection<T>
groupByUniqueKey
in interface RichIterable<T>
RichIterable.groupBy(Function)
public RichIterable<RichIterable<T>> chunk(int size)
RichIterable
chunk
in interface RichIterable<T>
size
- the number of elements per chunkRichIterable
containing RichIterable
s of size size
, except the last will be
truncated if the elements don't divide evenly.public T detect(Predicate<? super T> predicate)
RichIterable
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"); } });
detect
in interface RichIterable<T>
detect
in class AbstractRichIterable<T>
public <P> T detectWith(Predicate2<? super T,? super P> predicate, P parameter)
RichIterable
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");
detectWith
in interface RichIterable<T>
detectWith
in class AbstractRichIterable<T>
public Optional<T> detectOptional(Predicate<? super T> predicate)
RichIterable
Example 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> Optional<T> detectWithOptional(Predicate2<? super T,? super P> predicate, P parameter)
RichIterable
Example 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)
RichIterable
detectIfNone
in interface RichIterable<T>
public <P> T detectWithIfNone(Predicate2<? super T,? super P> predicate, P parameter, Function0<? extends T> function)
RichIterable
detectWithIfNone
in interface RichIterable<T>
detectWithIfNone
in class AbstractRichIterable<T>
public boolean anySatisfy(Predicate<? super T> predicate)
RichIterable
anySatisfy
in interface RichIterable<T>
anySatisfy
in class AbstractRichIterable<T>
public <P> boolean anySatisfyWith(Predicate2<? super T,? super P> predicate, P parameter)
RichIterable
anySatisfyWith
in interface RichIterable<T>
anySatisfyWith
in class AbstractRichIterable<T>
public boolean allSatisfy(Predicate<? super T> predicate)
RichIterable
allSatisfy
in interface RichIterable<T>
allSatisfy
in class AbstractRichIterable<T>
public <P> boolean allSatisfyWith(Predicate2<? super T,? super P> predicate, P parameter)
RichIterable
allSatisfyWith
in interface RichIterable<T>
allSatisfyWith
in class AbstractRichIterable<T>
public boolean noneSatisfy(Predicate<? super T> predicate)
RichIterable
noneSatisfy
in interface RichIterable<T>
noneSatisfy
in class AbstractRichIterable<T>
public <P> boolean noneSatisfyWith(Predicate2<? super T,? super P> predicate, P parameter)
RichIterable
noneSatisfyWith
in interface RichIterable<T>
noneSatisfyWith
in class AbstractRichIterable<T>
public <V> MutableBag<V> countBy(Function<? super T,? extends V> function)
RichIterable
countBy
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)
RichIterable
countByWith
in interface MutableCollection<T>
countByWith
in interface RichIterable<T>
public <V> MutableBag<V> countByEach(Function<? super T,? extends Iterable<V>> function)
RichIterable
countByEach
in interface MutableCollection<T>
countByEach
in interface RichIterable<T>
countByEach
in class AbstractRichIterable<T>
public T min()
RichIterable
min
in interface RichIterable<T>
min
in class AbstractRichIterable<T>
public T min(Comparator<? super T> comparator)
RichIterable
min
in interface RichIterable<T>
min
in class AbstractRichIterable<T>
public <V extends Comparable<? super V>> T minBy(Function<? super T,? extends V> function)
RichIterable
minBy
in interface RichIterable<T>
minBy
in class AbstractRichIterable<T>
public T max()
RichIterable
max
in interface RichIterable<T>
max
in class AbstractRichIterable<T>
public T max(Comparator<? super T> comparator)
RichIterable
max
in interface RichIterable<T>
max
in class AbstractRichIterable<T>
public <V extends Comparable<? super V>> T maxBy(Function<? super T,? extends V> function)
RichIterable
maxBy
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)
RichIterable
aggregateInPlaceBy
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)
RichIterable
aggregateBy
in interface MutableCollection<T>
aggregateBy
in interface RichIterable<T>
public <V> MutableObjectLongMap<V> sumByInt(Function<? super T,? extends V> groupBy, IntFunction<? super T> function)
RichIterable
sumByInt
in interface MutableCollection<T>
sumByInt
in interface RichIterable<T>
public <V> MutableObjectDoubleMap<V> sumByFloat(Function<? super T,? extends V> groupBy, FloatFunction<? super T> function)
RichIterable
sumByFloat
in interface MutableCollection<T>
sumByFloat
in interface RichIterable<T>
public <V> MutableObjectLongMap<V> sumByLong(Function<? super T,? extends V> groupBy, LongFunction<? super T> function)
RichIterable
sumByLong
in interface MutableCollection<T>
sumByLong
in interface RichIterable<T>
public <V> MutableObjectDoubleMap<V> sumByDouble(Function<? super T,? extends V> groupBy, DoubleFunction<? super T> function)
RichIterable
sumByDouble
in interface MutableCollection<T>
sumByDouble
in interface RichIterable<T>
public MutableList<ObjectIntPair<T>> topOccurrences(int n)
Bag
count
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)
Bag
count
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–2019. All rights reserved.