public final class Collectors2
extends java.lang.Object
A set of Collectors for Eclipse Collections types and algorithms.
Includes converter Collectors to{Immutable}{Sorted}{List/Set/Bag/Map/BiMap/Multimap}.
Includes Collectors for select, reject, partition.
Includes Collectors for collect, collect{Boolean/Byte/Char/Short/Int/Float/Long/Double}.
Includes Collectors for makeString, zip, chunk.
Includes Collectors for sumBy{Int/Float/Long/Double}.
Use these Collectors with @RichIterable.reduceInPlace(Collector)
and @Stream.collect(Collector)
.
Modifier and Type | Method | Description |
---|---|---|
static <T> java.util.stream.Collector<T,?,MutableList<MutableList<T>>> |
chunk(int size) |
Partitions elements in fixed size chunks.
|
static <T,V,R extends java.util.Collection<V>> |
collect(Function<? super T,? extends V> function,
java.util.function.Supplier<R> supplier) |
Returns a new collection with the results of applying the specified function on each element of the source
collection.
|
static <T,R extends MutableBooleanCollection> |
collectBoolean(BooleanFunction<? super T> function,
java.util.function.Supplier<R> supplier) |
Returns a new MutableBooleanCollection with the results of applying the specified BooleanFunction on each element
of the source.
|
static <T,R extends MutableByteCollection> |
collectByte(ByteFunction<? super T> function,
java.util.function.Supplier<R> supplier) |
Returns a new MutableByteCollection with the results of applying the specified ByteFunction on each element
of the source.
|
static <T,R extends MutableCharCollection> |
collectChar(CharFunction<? super T> function,
java.util.function.Supplier<R> supplier) |
Returns a new MutableCharCollection with the results of applying the specified CharFunction on each element
of the source.
|
static <T,R extends MutableDoubleCollection> |
collectDouble(DoubleFunction<? super T> function,
java.util.function.Supplier<R> supplier) |
Returns a new MutableDoubleCollection with the results of applying the specified DoubleFunction on each element
of the source.
|
static <T,R extends MutableFloatCollection> |
collectFloat(FloatFunction<? super T> function,
java.util.function.Supplier<R> supplier) |
Returns a new MutableFloatCollection with the results of applying the specified FloatFunction on each element
of the source.
|
static <T,R extends MutableIntCollection> |
collectInt(IntFunction<? super T> function,
java.util.function.Supplier<R> supplier) |
Returns a new MutableIntCollection with the results of applying the specified IntFunction on each element
of the source.
|
static <T,R extends MutableLongCollection> |
collectLong(LongFunction<? super T> function,
java.util.function.Supplier<R> supplier) |
Returns a new MutableLongCollection with the results of applying the specified LongFunction on each element
of the source.
|
static <T,R extends MutableShortCollection> |
collectShort(ShortFunction<? super T> function,
java.util.function.Supplier<R> supplier) |
Returns a new MutableShortCollection with the results of applying the specified ShortFunction on each element
of the source.
|
static <T,P,V,R extends java.util.Collection<V>> |
collectWith(Function2<? super T,? super P,? extends V> function,
P parameter,
java.util.function.Supplier<R> supplier) |
Returns a new collection with the results of applying the specified function on each element of the source
collection with the specified parameter.
|
static <T,K> java.util.stream.Collector<T,?,MutableBag<K>> |
countBy(Function<? super T,? extends K> function) |
Returns the counts of all of the values returned by applying the specified function to each
item of the Stream.
|
static <T,V,R extends java.util.Collection<V>> |
flatCollect(Function<? super T,? extends java.lang.Iterable<V>> function,
java.util.function.Supplier<R> supplier) |
The method
flatCollect is a special case of collect(Function, Supplier) . |
static <T,K,R extends MutableMultimap<K,T>> |
groupBy(Function<? super T,? extends K> groupBy,
java.util.function.Supplier<R> supplier) |
Returns the elements as an MutableMultimap grouping each element using the specified groupBy Function.
|
static <T,K,V,R extends MutableMultimap<K,V>> |
groupByAndCollect(Function<? super T,? extends K> groupBy,
Function<? super T,? extends V> valueFunction,
java.util.function.Supplier<R> supplier) |
Returns the elements as an MutableMultimap grouping each element using the specified groupBy Function and
converting each element to the value returned by applying the specified Function valueFunction.
|
static <T,K,R extends MutableMultimap<K,T>> |
groupByEach(Function<? super T,? extends java.lang.Iterable<K>> groupBy,
java.util.function.Supplier<R> supplier) |
Same as
groupBy(Function, Supplier) , except the result of evaluating groupBy function will return a
collection of keys for each value. |
static <T,K,R extends MutableMap<K,T>> |
groupByUniqueKey(Function<? super T,? extends K> groupBy,
java.util.function.Supplier<R> supplier) |
Same as
groupBy(Function, Supplier) , except the result of evaluating groupBy function should return a
unique key, or else an exception is thrown. |
static <T> java.util.stream.Collector<T,?,java.lang.String> |
makeString() |
Returns a String composed of elements separated by ", ".
|
static <T> java.util.stream.Collector<T,?,java.lang.String> |
makeString(java.lang.CharSequence separator) |
Returns a String composed of elements separated by the specified separator.
|
static <T> java.util.stream.Collector<T,?,java.lang.String> |
makeString(java.lang.CharSequence start,
java.lang.CharSequence separator,
java.lang.CharSequence end) |
Returns a String composed of elements separated by the specified separator and beginning with start
String and ending with end String.
|
static <T,R extends PartitionMutableCollection<T>> |
partition(Predicate<? super T> predicate,
java.util.function.Supplier<R> supplier) |
Returns all elements of the stream split into a PartitionMutableCollection after evaluating the predicate.
|
static <T,P,R extends PartitionMutableCollection<T>> |
partitionWith(Predicate2<? super T,? super P> predicate,
P parameter,
java.util.function.Supplier<R> supplier) |
Returns all elements of the stream split into a PartitionMutableCollection after evaluating the predicate.
|
static <T,R extends java.util.Collection<T>> |
reject(Predicate<? super T> predicate,
java.util.function.Supplier<R> supplier) |
Returns all elements of the stream that return false when evaluating the predicate.
|
static <T,P,R extends java.util.Collection<T>> |
rejectWith(Predicate2<? super T,? super P> predicate,
P parameter,
java.util.function.Supplier<R> supplier) |
Returns all elements of the stream that return false when evaluating the predicate with the parameter.
|
static <T,R extends java.util.Collection<T>> |
select(Predicate<? super T> predicate,
java.util.function.Supplier<R> supplier) |
Returns all elements of the stream that return true when evaluating the predicate.
|
static <T,P,R extends java.util.Collection<T>> |
selectWith(Predicate2<? super T,? super P> predicate,
P parameter,
java.util.function.Supplier<R> supplier) |
Returns all elements of the stream that return true when evaluating the predicate with the parameter.
|
static <T,V> java.util.stream.Collector<T,?,MutableMap<V,java.math.BigDecimal>> |
sumByBigDecimal(Function<? super T,? extends V> groupBy,
Function<? super T,java.math.BigDecimal> function) |
Groups and sums the values using the two specified functions.
|
static <T,V> java.util.stream.Collector<T,?,MutableMap<V,java.math.BigInteger>> |
sumByBigInteger(Function<? super T,? extends V> groupBy,
Function<? super T,java.math.BigInteger> function) |
Groups and sums the values using the two specified functions.
|
static <T,V> java.util.stream.Collector<T,?,MutableObjectDoubleMap<V>> |
sumByDouble(Function<? super T,? extends V> groupBy,
DoubleFunction<? super T> function) |
Groups and sums the values using the two specified functions.
|
static <T,V> java.util.stream.Collector<T,?,MutableObjectDoubleMap<V>> |
sumByFloat(Function<? super T,? extends V> groupBy,
FloatFunction<? super T> function) |
Groups and sums the values using the two specified functions.
|
static <T,V> java.util.stream.Collector<T,?,MutableObjectLongMap<V>> |
sumByInt(Function<? super T,? extends V> groupBy,
IntFunction<? super T> function) |
Groups and sums the values using the two specified functions.
|
static <T,V> java.util.stream.Collector<T,?,MutableObjectLongMap<V>> |
sumByLong(Function<? super T,? extends V> groupBy,
LongFunction<? super T> function) |
Groups and sums the values using the two specified functions.
|
static <T> java.util.stream.Collector<T,?,SummaryStatistics<T>> |
summarizing(ImmutableList<IntFunction<? super T>> intFunctions,
ImmutableList<LongFunction<? super T>> longFunctions,
ImmutableList<DoubleFunction<? super T>> doubleFunctions) |
Returns a SummaryStatistics with results for int, long and double functions calculated for
each element in the Stream or Collection this Collector is applied to.
|
static <T> java.util.stream.Collector<T,?,BigDecimalSummaryStatistics> |
summarizingBigDecimal(Function<? super T,java.math.BigDecimal> function) |
Returns a BigDecimalSummaryStatistics applying the specified function to each element of the stream or collection.
|
static <T> java.util.stream.Collector<T,?,BigIntegerSummaryStatistics> |
summarizingBigInteger(Function<? super T,java.math.BigInteger> function) |
Returns a BigIntegerSummaryStatistics applying the specified function to each element of the stream or collection.
|
static <T> java.util.stream.Collector<T,?,java.math.BigDecimal> |
summingBigDecimal(Function<? super T,java.math.BigDecimal> function) |
Returns a BigDecimal sum applying the specified function to each element of the stream or collection.
|
static <T> java.util.stream.Collector<T,?,java.math.BigInteger> |
summingBigInteger(Function<? super T,java.math.BigInteger> function) |
Returns a BigInteger sum applying the specified function to each element of the stream or collection.
|
static <T> java.util.stream.Collector<T,?,MutableBag<T>> |
toBag() |
Returns the elements as a MutableBag.
|
static <T,K> java.util.stream.Collector<T,?,MutableBagMultimap<K,T>> |
toBagMultimap(Function<? super T,? extends K> groupBy) |
Returns the elements as an MutableBagMultimap grouping each element using the specified groupBy Function.
|
static <T,K,V> java.util.stream.Collector<T,?,MutableBagMultimap<K,V>> |
toBagMultimap(Function<? super T,? extends K> groupBy,
Function<? super T,? extends V> valueFunction) |
Returns the elements as an MutableBagMultimap grouping each element using the specified groupBy Function and
converting each element to the value returned by applying the specified Function valueFunction.
|
static <T,K,V> java.util.stream.Collector<T,?,MutableBiMap<K,V>> |
toBiMap(Function<? super T,? extends K> keyFunction,
Function<? super T,? extends V> valueFunction) |
Returns the elements as a MutableBiMap applying the keyFunction and valueFunction to each element.
|
static <T> java.util.stream.Collector<T,?,ImmutableBag<T>> |
toImmutableBag() |
Returns the elements as an ImmutableBag.
|
static <T,K> java.util.stream.Collector<T,?,ImmutableBagMultimap<K,T>> |
toImmutableBagMultimap(Function<? super T,? extends K> groupBy) |
Returns the elements as an ImmutableBagMultimap grouping each element using the specified groupBy Function.
|
static <T,K,V> java.util.stream.Collector<T,?,ImmutableBagMultimap<K,V>> |
toImmutableBagMultimap(Function<? super T,? extends K> groupBy,
Function<? super T,? extends V> valueFunction) |
Returns the elements as an ImmutableBagMultimap grouping each element using the specified groupBy Function and
converting each element to the value returned by applying the specified Function valueFunction.
|
static <T,K,V> java.util.stream.Collector<T,?,ImmutableBiMap<K,V>> |
toImmutableBiMap(Function<? super T,? extends K> keyFunction,
Function<? super T,? extends V> valueFunction) |
Returns the elements as an ImmutableBiMap applying the keyFunction and valueFunction to each element.
|
static <T> java.util.stream.Collector<T,?,ImmutableList<T>> |
toImmutableList() |
Returns the elements as an ImmutableList.
|
static <T,K> java.util.stream.Collector<T,?,ImmutableListMultimap<K,T>> |
toImmutableListMultimap(Function<? super T,? extends K> groupBy) |
Returns the elements as an ImmutableListMultimap grouping each element using the specified groupBy Function.
|
static <T,K,V> java.util.stream.Collector<T,?,ImmutableListMultimap<K,V>> |
toImmutableListMultimap(Function<? super T,? extends K> groupBy,
Function<? super T,? extends V> valueFunction) |
Returns the elements as an ImmutableListMultimap grouping each element using the specified groupBy Function and
converting each element to the value returned by applying the specified Function valueFunction.
|
static <T,K,V> java.util.stream.Collector<T,?,ImmutableMap<K,V>> |
toImmutableMap(Function<? super T,? extends K> keyFunction,
Function<? super T,? extends V> valueFunction) |
Returns the elements as an ImmutableMap applying the keyFunction and valueFunction to each element.
|
static <T> java.util.stream.Collector<T,?,ImmutableSet<T>> |
toImmutableSet() |
Returns the elements as an ImmutableSet.
|
static <T,K> java.util.stream.Collector<T,?,ImmutableSetMultimap<K,T>> |
toImmutableSetMultimap(Function<? super T,? extends K> groupBy) |
Returns the elements as an ImmutableSetMultimap grouping each element using the specified groupBy Function.
|
static <T,K,V> java.util.stream.Collector<T,?,ImmutableSetMultimap<K,V>> |
toImmutableSetMultimap(Function<? super T,? extends K> groupBy,
Function<? super T,? extends V> valueFunction) |
Returns the elements as an ImmutableSetMultimap grouping each element using the specified groupBy Function and
converting each element to the value returned by applying the specified Function valueFunction.
|
static <T> java.util.stream.Collector<T,?,ImmutableSortedBag<T>> |
toImmutableSortedBag() |
Returns the elements as an ImmutableSortedBag.
|
static <T> java.util.stream.Collector<T,?,ImmutableSortedBag<T>> |
toImmutableSortedBag(java.util.Comparator<? super T> comparator) |
Returns the elements as an ImmutableSortedBag using the specified comparator.
|
static <T> java.util.stream.Collector<T,?,ImmutableList<T>> |
toImmutableSortedList() |
Returns the elements as an ImmutableList that has been sorted.
|
static <T> java.util.stream.Collector<T,?,ImmutableList<T>> |
toImmutableSortedList(java.util.Comparator<? super T> comparator) |
Returns the elements as an ImmutableList that has been sorted using the specified comparator.
|
static <T> java.util.stream.Collector<T,?,ImmutableSortedSet<T>> |
toImmutableSortedSet() |
Returns the elements as an ImmutableSortedSet.
|
static <T> java.util.stream.Collector<T,?,ImmutableSortedSet<T>> |
toImmutableSortedSet(java.util.Comparator<? super T> comparator) |
Returns the elements as an ImmutableSortedSet using the specified comparator.
|
static <T> java.util.stream.Collector<T,?,ImmutableStack<T>> |
toImmutableStack() |
Returns the elements as an ImmutableStack.
|
static <T> java.util.stream.Collector<T,?,MutableList<T>> |
toList() |
Returns the elements as a MutableList.
|
static <T,K> java.util.stream.Collector<T,?,MutableListMultimap<K,T>> |
toListMultimap(Function<? super T,? extends K> groupBy) |
Returns the elements as an MutableListMultimap grouping each element using the specified groupBy Function.
|
static <T,K,V> java.util.stream.Collector<T,?,MutableListMultimap<K,V>> |
toListMultimap(Function<? super T,? extends K> groupBy,
Function<? super T,? extends V> valueFunction) |
Returns the elements as an MutableListMultimap grouping each element using the specified groupBy Function and
converting each element to the value returned by applying the specified Function valueFunction.
|
static <T,K,V> java.util.stream.Collector<T,?,MutableMap<K,V>> |
toMap(Function<? super T,? extends K> keyFunction,
Function<? super T,? extends V> valueFunction) |
Returns the elements as a MutableMap applying the keyFunction and valueFunction to each element.
|
static <T> java.util.stream.Collector<T,?,MutableSet<T>> |
toSet() |
Returns the elements as a MutableSet.
|
static <T,K> java.util.stream.Collector<T,?,MutableSetMultimap<K,T>> |
toSetMultimap(Function<? super T,? extends K> groupBy) |
Returns the elements as an MutableSetMultimap grouping each element using the specified groupBy Function.
|
static <T,K,V> java.util.stream.Collector<T,?,MutableSetMultimap<K,V>> |
toSetMultimap(Function<? super T,? extends K> groupBy,
Function<? super T,? extends V> valueFunction) |
Returns the elements as an MutableSetMultimap grouping each element using the specified groupBy Function and
converting each element to the value returned by applying the specified Function valueFunction.
|
static <T> java.util.stream.Collector<T,?,MutableSortedBag<T>> |
toSortedBag() |
Returns the elements as a MutableSortedBag.
|
static <T> java.util.stream.Collector<T,?,MutableSortedBag<T>> |
toSortedBag(java.util.Comparator<? super T> comparator) |
Returns the elements as a MutableSortedBag using the specified comparator.
|
static <T,V extends java.lang.Comparable<? super V>> |
toSortedBagBy(Function<? super T,? extends V> function) |
Returns the elements as a MutableSortedBag using the specified function.
|
static <T> java.util.stream.Collector<T,?,MutableList<T>> |
toSortedList() |
Returns the elements as a MutableList that has been sorted.
|
static <T> java.util.stream.Collector<T,?,MutableList<T>> |
toSortedList(java.util.Comparator<? super T> comparator) |
Returns the elements as a MutableList that has been sorted using the specified comparator.
|
static <T,V extends java.lang.Comparable<? super V>> |
toSortedListBy(Function<? super T,? extends V> function) |
Returns the elements as a MutableList that has been sorted using the specified comparator.
|
static <T> java.util.stream.Collector<T,?,MutableSortedSet<T>> |
toSortedSet() |
Returns the elements as a MutableSortedSet.
|
static <T> java.util.stream.Collector<T,?,MutableSortedSet<T>> |
toSortedSet(java.util.Comparator<? super T> comparator) |
Returns the elements as a MutableSortedSet using the specified comparator.
|
static <T,V extends java.lang.Comparable<? super V>> |
toSortedSetBy(Function<? super T,? extends V> function) |
Returns the elements as a MutableSortedSet using the specified function to compare each element.
|
static <T> java.util.stream.Collector<T,?,MutableStack<T>> |
toStack() |
Returns the elements as a MutableStack.
|
static <T,S> java.util.stream.Collector<T,?,MutableList<Pair<T,S>>> |
zip(java.lang.Iterable<S> other) |
Returns a
MutableList formed from this stream of elements and another Iterable by
combining corresponding elements in pairs. |
static <T> java.util.stream.Collector<T,?,MutableList<ObjectIntPair<T>>> |
zipWithIndex() |
Returns a
MutableList of pairs formed from this stream of elements its indices. |
public static <T> java.util.stream.Collector<T,?,java.lang.String> makeString()
Returns a String composed of elements separated by ", ".
Examples:
System.out.println(Interval.oneTo(5).stream().collect(Collectors2.makeString()));
System.out.println(Interval.oneTo(5).reduceInPlace(Collectors2.makeString()));
Prints:
1, 2, 3, 4, 5 1, 2, 3, 4, 5
Equivalent to using @RichIterable.makeString()
System.out.println(Interval.oneTo(5).makeString());
public static <T> java.util.stream.Collector<T,?,java.lang.String> makeString(java.lang.CharSequence separator)
Returns a String composed of elements separated by the specified separator.
Examples:
System.out.println(Interval.oneTo(5).stream().collect(Collectors2.makeString("")));
System.out.println(Interval.oneTo(5).reduceInPlace(Collectors2.makeString("")));
Prints:
12345 12345
Equivalent to using @RichIterable.makeString(String)
System.out.println(Interval.oneTo(5).makeString(""));
public static <T> java.util.stream.Collector<T,?,java.lang.String> makeString(java.lang.CharSequence start, java.lang.CharSequence separator, java.lang.CharSequence end)
Returns a String composed of elements separated by the specified separator and beginning with start String and ending with end String.
Examples:
System.out.println(Interval.oneTo(5).stream().collect(Collectors2.makeString("[", ":", "]")));
System.out.println(Interval.oneTo(5).reduceInPlace(Collectors2.makeString("[", ":", "]")));
Prints:
[1:2:3:4:5] [1:2:3:4:5]
Equivalent to using @RichIterable.makeString(String, String, String)
}
System.out.println(Interval.oneTo(5).makeString("[", ":", "]"));
public static <T> java.util.stream.Collector<T,?,MutableList<T>> toList()
Returns the elements as a MutableList.
Examples:
MutableList<Integer> numbers1 = Interval.oneTo(5).stream().collect(Collectors2.toList());
MutableList<Integer> numbers2 = Interval.oneTo(5).reduceInPlace(Collectors2.toList());
Equivalent to using @RichIterable.toList()
}
MutableList<Integer> numbers = Interval.oneTo(5).toList();
public static <T> java.util.stream.Collector<T,?,ImmutableList<T>> toImmutableList()
Returns the elements as an ImmutableList.
Examples:
ImmutableList<Integer> numbers1 = Interval.oneTo(5).stream().collect(Collectors2.toImmutableList());
ImmutableList<Integer> numbers2 = Interval.oneTo(5).reduceInPlace(Collectors2.toImmutableList());
Equivalent to using @RichIterable.toList()
followed by: @MutableList.toImmutable()
.
ImmutableList<Integer> numbers = Interval.oneTo(5).toList().toImmutable();
public static <T> java.util.stream.Collector<T,?,MutableSet<T>> toSet()
Returns the elements as a MutableSet.
Examples:
MutableSet<Integer> set1 = Interval.oneTo(5).stream().collect(Collectors2.toSet());
MutableSet<Integer> set2 =Interval.oneTo(5).reduceInPlace(Collectors2.toSet());
Equivalent to using @RichIterable.toSet()
}
MutableSet<Integer> set = Interval.oneTo(5).toSet();
public static <T> java.util.stream.Collector<T,?,ImmutableSet<T>> toImmutableSet()
Returns the elements as an ImmutableSet.
Examples:
ImmutableSet<Integer> set1 = Interval.oneTo(5).stream().collect(Collectors2.toImmutableSet());
ImmutableSet<Integer> set2 = Interval.oneTo(5).reduceInPlace(Collectors2.toImmutableSet());
Equivalent to using @RichIterable.toSet()
followed by: @MutableSet.toImmutable()
.
ImmutableSet<Integer> set = Interval.oneTo(5).toSet().toImmutable();
public static <T> java.util.stream.Collector<T,?,MutableSortedSet<T>> toSortedSet()
Returns the elements as a MutableSortedSet.
Examples:
MutableSortedSet<Integer> set1 = Interval.oneTo(5).stream().collect(Collectors2.toSortedSet());
MutableSortedSet<Integer> set2 = Interval.oneTo(5).reduceInPlace(Collectors2.toSortedSet());
Equivalent to using @RichIterable.toSortedSet()
}.
MutableSortedSet<Integer> set = Interval.oneTo(5).toSortedSet();
public static <T> java.util.stream.Collector<T,?,ImmutableSortedSet<T>> toImmutableSortedSet()
Returns the elements as an ImmutableSortedSet.
Examples:
ImmutableSortedSet<Integer> set1 = Interval.oneTo(5).stream().collect(Collectors2.toImmutableSortedSet());
ImmutableSortedSet<Integer> set2 = Interval.oneTo(5).reduceInPlace(Collectors2.toImmutableSortedSet());
Equivalent to using @RichIterable.toSortedSet()
followed by: @MutableSortedSet.toImmutable()
.
ImmutableSortedSet<Integer> set = Interval.oneTo(5).toSortedSet().toImmutable();
public static <T> java.util.stream.Collector<T,?,MutableSortedSet<T>> toSortedSet(java.util.Comparator<? super T> comparator)
Returns the elements as a MutableSortedSet using the specified comparator.
Examples:
MutableSortedSet<Integer> set1 = Interval.oneTo(5).stream().collect(Collectors2.toSortedSet(Comparator.naturalOrder()));
MutableSortedSet<Integer> set2 = Interval.oneTo(5).reduceInPlace(Collectors2.toSortedSet(Comparator.naturalOrder()));
Equivalent to using @RichIterable.toSortedSet(Comparator)
.
MutableSortedSet<Integer> set = Interval.oneTo(5).toSortedSet(Comparator.naturalOrder());
public static <T,V extends java.lang.Comparable<? super V>> java.util.stream.Collector<T,?,MutableSortedSet<T>> toSortedSetBy(Function<? super T,? extends V> function)
Returns the elements as a MutableSortedSet using the specified function to compare each element.
Examples:
MutableSortedSet<Integer> set1 = Interval.oneTo(5).stream().collect(Collectors2.toSortedSetBy(Object::toString));
MutableSortedSet<Integer> set2 = Interval.oneTo(5).reduceInPlace(Collectors2.toSortedSetBy(Object::toString));
Equivalent to using @RichIterable.toSortedSetBy(Function)
.
MutableSortedSet<Integer> set = Interval.oneTo(5).toSortedSetBy(Object::toString);
public static <T> java.util.stream.Collector<T,?,ImmutableSortedSet<T>> toImmutableSortedSet(java.util.Comparator<? super T> comparator)
Returns the elements as an ImmutableSortedSet using the specified comparator.
Examples:
ImmutableSortedSet<Integer> set1 = Interval.oneTo(5).stream().collect(Collectors2.toImmutableSortedSet(Comparator.naturalOrder()));
ImmutableSortedSet<Integer> set2 = Interval.oneTo(5).reduceInPlace(Collectors2.toImmutableSortedSet(Comparator.naturalOrder()));
Equivalent to using @RichIterable.toSortedSet(Comparator)
followed by: @MutableSortedSet.toImmutable()
.
ImmutableSortedSet<Integer> set = Interval.oneTo(5).toSortedSet(Comparator.naturalOrder()).toImmutable();
public static <T> java.util.stream.Collector<T,?,MutableBag<T>> toBag()
Returns the elements as a MutableBag.
Examples:
MutableBag<Integer> bag1 = Interval.oneTo(5).stream().collect(Collectors2.toBag());
MutableBag<Integer> bag2 = Interval.oneTo(5).reduceInPlace(Collectors2.toBag());
Equivalent to using @RichIterable.toBag()
}
MutableBag<Integer> bag = Interval.oneTo(5).toBag();
public static <T> java.util.stream.Collector<T,?,ImmutableBag<T>> toImmutableBag()
Returns the elements as an ImmutableBag.
Examples:
ImmutableBag<Integer> bag1 = Interval.oneTo(5).stream().collect(Collectors2.toImmutableBag());
ImmutableBag<Integer> bag2 = Interval.oneTo(5).reduceInPlace(Collectors2.toImmutableBag());
Equivalent to using @RichIterable.toBag()
followed by: @MutableBag.toImmutable()
.
ImmutableBag<Integer> bag = Interval.oneTo(5).toBag().toImmutable();
public static <T> java.util.stream.Collector<T,?,MutableList<T>> toSortedList()
Returns the elements as a MutableList that has been sorted.
Examples:
MutableList<Integer> list1 = Interval.oneTo(5).stream().collect(Collectors2.toSortedList());
MutableList<Integer> list2 = Interval.oneTo(5).reduceInPlace(Collectors2.toSortedList());
Equivalent to using @RichIterable.toSortedList()
}
MutableList<Integer> list = Interval.oneTo(5).toSortedList();
public static <T> java.util.stream.Collector<T,?,ImmutableList<T>> toImmutableSortedList()
Returns the elements as an ImmutableList that has been sorted.
Examples:
ImmutableList<Integer> list1 = Interval.oneTo(5).stream().collect(Collectors2.toImmutableSortedList());
ImmutableList<Integer> list2 = Interval.oneTo(5).reduceInPlace(Collectors2.toImmutableSortedList());
Equivalent to using @RichIterable.toSortedList()
followed by: @MutableList.toImmutable()
.
ImmutableList<Integer> list = Interval.oneTo(5).toSortedList().toImmutable();
public static <T> java.util.stream.Collector<T,?,MutableList<T>> toSortedList(java.util.Comparator<? super T> comparator)
Returns the elements as a MutableList that has been sorted using the specified comparator.
Examples:
MutableList<Integer> list1 = Interval.oneTo(5).stream().collect(Collectors2.toSortedList(Comparators.naturalOrder()));
MutableList<Integer> list2 = Interval.oneTo(5).reduceInPlace(Collectors2.toSortedList(Comparators.naturalOrder()));
Equivalent to using @RichIterable.toSortedList(Comparator)
}
MutableList<Integer> list = Interval.oneTo(5).toSortedList(Comparators.naturalOrder());
public static <T,V extends java.lang.Comparable<? super V>> java.util.stream.Collector<T,?,MutableList<T>> toSortedListBy(Function<? super T,? extends V> function)
Returns the elements as a MutableList that has been sorted using the specified comparator.
Examples:
MutableList<Integer> list1 = Interval.oneTo(5).stream().collect(Collectors2.toSortedListBy(Object::toString));
MutableList<Integer> list2 = Interval.oneTo(5).reduceInPlace(Collectors2.toSortedListBy(Object::toString));
Equivalent to using @RichIterable.toSortedListBy(Function)
}
MutableList<Integer> list = Interval.oneTo(5).toSortedListBy(Object::toString);
public static <T> java.util.stream.Collector<T,?,ImmutableList<T>> toImmutableSortedList(java.util.Comparator<? super T> comparator)
Returns the elements as an ImmutableList that has been sorted using the specified comparator.
Examples:
ImmutableList<Integer> list1 = Interval.oneTo(5).stream().collect(Collectors2.toImmutableSortedList(Comparator.naturalOrder()));
ImmutableList<Integer> list2 = Interval.oneTo(5).reduceInPlace(Collectors2.toImmutableSortedList(Comparator.naturalOrder()));
Equivalent to using @RichIterable.toSortedList(Comparator)
followed by: @MutableList.toImmutable()
.
ImmutableList<Integer> list = Interval.oneTo(5).toSortedList(Comparator.naturalOrder()).toImmutable();
public static <T> java.util.stream.Collector<T,?,MutableSortedBag<T>> toSortedBag()
Returns the elements as a MutableSortedBag.
Examples:
MutableSortedBag<Integer> bag1 = Interval.oneTo(5).stream().collect(Collectors2.toSortedBag());
MutableSortedBag<Integer> bag2 = Interval.oneTo(5).reduceInPlace(Collectors2.toSortedBag());
Equivalent to using @RichIterable.toSortedBag()
}
MutableSortedBag<Integer> bag = Interval.oneTo(5).toSortedBag();
public static <T> java.util.stream.Collector<T,?,ImmutableSortedBag<T>> toImmutableSortedBag()
Returns the elements as an ImmutableSortedBag.
Examples:
ImmutableSortedBag<Integer> bag1 = Interval.oneTo(5).stream().collect(Collectors2.toImmutableSortedBag());
ImmutableSortedBag<Integer> bag2 = Interval.oneTo(5).reduceInPlace(Collectors2.toImmutableSortedBag());
Equivalent to using @RichIterable.toSortedBag()
followed by: @MutableList.toImmutable()
.
ImmutableSortedBag<Integer> bag = Interval.oneTo(5).toSortedBag().toImmutable();
public static <T> java.util.stream.Collector<T,?,MutableSortedBag<T>> toSortedBag(java.util.Comparator<? super T> comparator)
Returns the elements as a MutableSortedBag using the specified comparator.
Examples:
MutableSortedBag<Integer> bag1 = Interval.oneTo(5).stream().collect(Collectors2.toSortedBag(Comparators.naturalOrder()));
MutableSortedBag<Integer> bag2 = Interval.oneTo(5).reduceInPlace(Collectors2.toSortedBag(Comparators.naturalOrder()));
Equivalent to using @RichIterable.toSortedBag(Comparator)
MutableSortedBag<Integer> bag = Interval.oneTo(5).toSortedBag(Comparators.naturalOrder());
public static <T,V extends java.lang.Comparable<? super V>> java.util.stream.Collector<T,?,MutableSortedBag<T>> toSortedBagBy(Function<? super T,? extends V> function)
Returns the elements as a MutableSortedBag using the specified function.
Examples:
MutableSortedBag<Integer> bag1 = Interval.oneTo(5).stream().collect(Collectors2.toSortedBagBy(Object::toString));
MutableSortedBag<Integer> bag2 = Interval.oneTo(5).reduceInPlace(Collectors2.toSortedBagBy(Object::toString));
Equivalent to using @RichIterable.toSortedBagBy(Function)
}
MutableSortedBag<Integer> bag = Interval.oneTo(5).toSortedBagBy(Object::toString);
public static <T> java.util.stream.Collector<T,?,ImmutableSortedBag<T>> toImmutableSortedBag(java.util.Comparator<? super T> comparator)
Returns the elements as an ImmutableSortedBag using the specified comparator.
Examples:
ImmutableSortedBag<Integer> bag1 = Interval.oneTo(5).stream().collect(Collectors2.toImmutableSortedBag(Comparator.naturalOrder()));
ImmutableSortedBag<Integer> bag1 = Interval.oneTo(5).reduceInPlace(Collectors2.toImmutableSortedBag(Comparator.naturalOrder()));
Equivalent to using @RichIterable.toSortedBag(Comparator)
followed by: @MutableBag.toImmutable()
.
ImmutableSortedBag<Integer> bag = Interval.oneTo(5).toSortedBag(Comparator.naturalOrder()).toImmutable();
public static <T> java.util.stream.Collector<T,?,MutableStack<T>> toStack()
Returns the elements as a MutableStack.
Examples:
MutableStack<Integer> stack1 = Interval.oneTo(5).stream().collect(Collectors2.toStack());
MutableStack<Integer> stack2 = Interval.oneTo(5).reduceInPlace(Collectors2.toStack());
Equivalent to using @OrderedIterable.toStack()
}
MutableStack<Integer> stack = Interval.oneTo(5).toList().toStack();
public static <T> java.util.stream.Collector<T,?,ImmutableStack<T>> toImmutableStack()
Returns the elements as an ImmutableStack.
Examples:
ImmutableStack<Integer> stack1 = Interval.oneTo(5).stream().collect(Collectors2.toImmutableStack());
ImmutableStack<Integer> stack2 = Interval.oneTo(5).reduceInPlace(Collectors2.toImmutableStack());
Equivalent to using @OrderedIterable.toStack()
followed by: @StackIterable.toImmutable()
}
ImmutableStack<Integer> stack = Interval.oneTo(5).toList().toStack().toImmutable();
public static <T,K,V> java.util.stream.Collector<T,?,MutableBiMap<K,V>> toBiMap(Function<? super T,? extends K> keyFunction, Function<? super T,? extends V> valueFunction)
Returns the elements as a MutableBiMap applying the keyFunction and valueFunction to each element.
Examples:
BiMap<Integer, String> biMap1 =
Interval.oneTo(5).stream().collect(Collectors2.toBiMap(Functions.identity(), Object::toString));
BiMap<Integer, String> biMap1 =
Interval.oneTo(5).reduceInPlace(Collectors2.toBiMap(Functions.identity(), Object::toString));
public static <T,K,V> java.util.stream.Collector<T,?,ImmutableBiMap<K,V>> toImmutableBiMap(Function<? super T,? extends K> keyFunction, Function<? super T,? extends V> valueFunction)
Returns the elements as an ImmutableBiMap applying the keyFunction and valueFunction to each element.
Examples:
MutableBiMap<Integer, String> biMap1 =
Interval.oneTo(5).stream().collect(Collectors2.toImmutableBiMap(Functions.identity(), Object::toString));
MutableBiMap<Integer, String> biMap2 =
Interval.oneTo(5).reduceInPlace(Collectors2.toImmutableBiMap(Functions.identity(), Object::toString));
public static <T,K,V> java.util.stream.Collector<T,?,MutableMap<K,V>> toMap(Function<? super T,? extends K> keyFunction, Function<? super T,? extends V> valueFunction)
Returns the elements as a MutableMap applying the keyFunction and valueFunction to each element.
Examples:
MutableMap<Integer, String> map1 =
Interval.oneTo(5).stream().collect(Collectors2.toMap(Functions.identity(), Object::toString));
MutableMap<Integer, String> map2 =
Interval.oneTo(5).reduceInPlace(Collectors2.toMap(Functions.identity(), Object::toString));
Equivalent to using @RichIterable.toMap(Function, Function)
MutableMap<Integer, String> map = Interval.oneTo(5).toMap(Functions.identity(), Object::toString);
public static <T,K,V> java.util.stream.Collector<T,?,ImmutableMap<K,V>> toImmutableMap(Function<? super T,? extends K> keyFunction, Function<? super T,? extends V> valueFunction)
Returns the elements as an ImmutableMap applying the keyFunction and valueFunction to each element.
Examples:
ImmutableMap<Integer, String> map1 =
Interval.oneTo(5).stream().collect(Collectors2.toImmutableMap(Functions.identity(), Object::toString));
ImmutableMap<Integer, String> map2 =
Interval.oneTo(5).reduceInPlace(Collectors2.toImmutableMap(Functions.identity(), Object::toString));
Equivalent to using @RichIterable.toMap(Function, Function)
ImmutableMap<Integer, String> map = Interval.oneTo(5).toMap(Functions.identity(), Object::toString).toImmutable();
public static <T,K> java.util.stream.Collector<T,?,MutableBag<K>> countBy(Function<? super T,? extends K> function)
public static <T,K,R extends MutableMultimap<K,T>> java.util.stream.Collector<T,?,R> groupBy(Function<? super T,? extends K> groupBy, java.util.function.Supplier<R> supplier)
Returns the elements as an MutableMultimap grouping each element using the specified groupBy Function.
Examples:
MutableListMultimap<String, Integer> multimap1 =
Interval.oneTo(5).stream().collect(Collectors2.groupBy(Object::toString, Multimaps.mutable.list::empty));
MutableListMultimap<String, Integer> multimap2 =
Interval.oneTo(5).reduceInPlace(Collectors2.groupBy(Object::toString, Multimaps.mutable.list::empty));
Equivalent to using @RichIterable.groupBy(Function, MutableMultimap)
MutableListMultimap<String, Integer> multimap = Interval.oneTo(5).groupBy(Object::toString, Multimaps.mutable.list.empty());
public static <T,K,R extends MutableMultimap<K,T>> java.util.stream.Collector<T,?,R> groupByEach(Function<? super T,? extends java.lang.Iterable<K>> groupBy, java.util.function.Supplier<R> supplier)
Same as groupBy(Function, Supplier)
, except the result of evaluating groupBy function will return a
collection of keys for each value.
Equivalent to using @RichIterable.groupByEach(Function, MutableMultimap)
public static <T,K,R extends MutableMap<K,T>> java.util.stream.Collector<T,?,R> groupByUniqueKey(Function<? super T,? extends K> groupBy, java.util.function.Supplier<R> supplier)
Same as groupBy(Function, Supplier)
, except the result of evaluating groupBy function should return a
unique key, or else an exception is thrown.
Equivalent to using @RichIterable.groupByUniqueKey(Function, MutableMap)
public static <T,K,V,R extends MutableMultimap<K,V>> java.util.stream.Collector<T,?,R> groupByAndCollect(Function<? super T,? extends K> groupBy, Function<? super T,? extends V> valueFunction, java.util.function.Supplier<R> supplier)
Returns the elements as an MutableMultimap grouping each element using the specified groupBy Function and converting each element to the value returned by applying the specified Function valueFunction.
Examples:
MutableListMultimap<String, String> multimap1 =
Interval.oneTo(5).stream().collect(Collectors2.groupByAndCollect(Object::toString, Object::toString, Multimaps.mutable.list::empty));
MutableListMultimap<String, String> multimap2 =
Interval.oneTo(5).reduceInPlace(Collectors2.groupByAndCollect(Object::toString, Object::toString, Multimaps.mutable.list::empty));
public static <T,K> java.util.stream.Collector<T,?,MutableListMultimap<K,T>> toListMultimap(Function<? super T,? extends K> groupBy)
Returns the elements as an MutableListMultimap grouping each element using the specified groupBy Function.
Examples:
MutableListMultimap<String, Integer> multimap1 =
Interval.oneTo(5).stream().collect(Collectors2.toListMultimap(Object::toString));
MutableListMultimap<String, Integer> multimap2 =
Interval.oneTo(5).reduceInPlace(Collectors2.toListMultimap(Object::toString));
public static <T,K,V> java.util.stream.Collector<T,?,MutableListMultimap<K,V>> toListMultimap(Function<? super T,? extends K> groupBy, Function<? super T,? extends V> valueFunction)
Returns the elements as an MutableListMultimap grouping each element using the specified groupBy Function and converting each element to the value returned by applying the specified Function valueFunction.
Examples:
MutableListMultimap<String, String> multimap1 =
Interval.oneTo(5).stream().collect(Collectors2.toListMultimap(Object::toString, Object::toString));
MutableListMultimap<String, String> multimap2 =
Interval.oneTo(5).reduceInPlace(Collectors2.toListMultimap(Object::toString, Object::toString));
public static <T,K> java.util.stream.Collector<T,?,MutableSetMultimap<K,T>> toSetMultimap(Function<? super T,? extends K> groupBy)
Returns the elements as an MutableSetMultimap grouping each element using the specified groupBy Function.
Examples:
MutableSetMultimap<String, Integer> multimap1 =
Interval.oneTo(5).stream().collect(Collectors2.toSetMultimap(Object::toString));
MutableSetMultimap<String, Integer> multimap2 =
Interval.oneTo(5).reduceInPlace(Collectors2.toSetMultimap(Object::toString));
public static <T,K,V> java.util.stream.Collector<T,?,MutableSetMultimap<K,V>> toSetMultimap(Function<? super T,? extends K> groupBy, Function<? super T,? extends V> valueFunction)
Returns the elements as an MutableSetMultimap grouping each element using the specified groupBy Function and converting each element to the value returned by applying the specified Function valueFunction.
Examples:
MutableSetMultimap<String, String> multimap1 =
Interval.oneTo(5).stream().collect(Collectors2.toSetMultimap(Object::toString, Object::toString));
MutableSetMultimap<String, String> multimap2 =
Interval.oneTo(5).reduceInPlace(Collectors2.toSetMultimap(Object::toString, Object::toString));
public static <T,K> java.util.stream.Collector<T,?,MutableBagMultimap<K,T>> toBagMultimap(Function<? super T,? extends K> groupBy)
Returns the elements as an MutableBagMultimap grouping each element using the specified groupBy Function.
Examples:
MutableBagMultimap<String, Integer> multimap1 =
Interval.oneTo(5).stream().collect(Collectors2.toBagMultimap(Object::toString));
MutableBagMultimap<String, Integer> multimap2 =
Interval.oneTo(5).reduceInPlace(Collectors2.toBagMultimap(Object::toString));
public static <T,K,V> java.util.stream.Collector<T,?,MutableBagMultimap<K,V>> toBagMultimap(Function<? super T,? extends K> groupBy, Function<? super T,? extends V> valueFunction)
Returns the elements as an MutableBagMultimap grouping each element using the specified groupBy Function and converting each element to the value returned by applying the specified Function valueFunction.
Examples:
MutableBagMultimap<String, String> multimap1 =
Interval.oneTo(5).stream().collect(Collectors2.toBagMultimap(Object::toString, Object::toString));
MutableBagMultimap<String, String> multimap2 =
Interval.oneTo(5).reduceInPlace(Collectors2.toBagMultimap(Object::toString, Object::toString));
public static <T,K> java.util.stream.Collector<T,?,ImmutableListMultimap<K,T>> toImmutableListMultimap(Function<? super T,? extends K> groupBy)
Returns the elements as an ImmutableListMultimap grouping each element using the specified groupBy Function.
Examples:
ImmutableListMultimap<String, Integer> multimap1 =
Interval.oneTo(5).stream().collect(Collectors2.toImmutableListMultimap(Object::toString));
ImmutableListMultimap<String, Integer> multimap2 =
Interval.oneTo(5).reduceInPlace(Collectors2.toImmutableListMultimap(Object::toString));
public static <T,K,V> java.util.stream.Collector<T,?,ImmutableListMultimap<K,V>> toImmutableListMultimap(Function<? super T,? extends K> groupBy, Function<? super T,? extends V> valueFunction)
Returns the elements as an ImmutableListMultimap grouping each element using the specified groupBy Function and converting each element to the value returned by applying the specified Function valueFunction.
Examples:
ImmutableListMultimap<String, String> multimap1 =
Interval.oneTo(5).stream().collect(Collectors2.toImmutableListMultimap(Object::toString, Object::toString));
ImmutableListMultimap<String, String> multimap2 =
Interval.oneTo(5).reduceInPlace(Collectors2.toImmutableListMultimap(Object::toString, Object::toString));
public static <T,K> java.util.stream.Collector<T,?,ImmutableSetMultimap<K,T>> toImmutableSetMultimap(Function<? super T,? extends K> groupBy)
Returns the elements as an ImmutableSetMultimap grouping each element using the specified groupBy Function.
Examples:
ImmutableSetMultimap<String, Integer> multimap1 =
Interval.oneTo(5).stream().collect(Collectors2.toImmutableSetMultimap(Object::toString));
ImmutableSetMultimap<String, Integer> multimap2 =
Interval.oneTo(5).reduceInPlace(Collectors2.toImmutableSetMultimap(Object::toString));
public static <T,K,V> java.util.stream.Collector<T,?,ImmutableSetMultimap<K,V>> toImmutableSetMultimap(Function<? super T,? extends K> groupBy, Function<? super T,? extends V> valueFunction)
Returns the elements as an ImmutableSetMultimap grouping each element using the specified groupBy Function and converting each element to the value returned by applying the specified Function valueFunction.
Examples:
ImmutableSetMultimap<String, String> multimap1 =
Interval.oneTo(5).stream().collect(Collectors2.toImmutableSetMultimap(Object::toString, Object::toString));
ImmutableSetMultimap<String, String> multimap2 =
Interval.oneTo(5).reduceInPlace(Collectors2.toImmutableSetMultimap(Object::toString, Object::toString));
public static <T,K> java.util.stream.Collector<T,?,ImmutableBagMultimap<K,T>> toImmutableBagMultimap(Function<? super T,? extends K> groupBy)
Returns the elements as an ImmutableBagMultimap grouping each element using the specified groupBy Function.
Examples:
ImmutableBagMultimap<String, Integer> multimap1 =
Interval.oneTo(5).stream().collect(Collectors2.toImmutableBagMultimap(Object::toString));
ImmutableBagMultimap<String, Integer> multimap2 =
Interval.oneTo(5).reduceInPlace(Collectors2.toImmutableBagMultimap(Object::toString));
public static <T,K,V> java.util.stream.Collector<T,?,ImmutableBagMultimap<K,V>> toImmutableBagMultimap(Function<? super T,? extends K> groupBy, Function<? super T,? extends V> valueFunction)
Returns the elements as an ImmutableBagMultimap grouping each element using the specified groupBy Function and converting each element to the value returned by applying the specified Function valueFunction.
Examples:
ImmutableBagMultimap<String, String> multimap1 =
Interval.oneTo(5).stream().collect(Collectors2.toImmutableBagMultimap(Object::toString, Object::toString));
ImmutableBagMultimap<String, String> multimap2 =
Interval.oneTo(5).reduceInPlace(Collectors2.toImmutableBagMultimap(Object::toString, Object::toString));
public static <T> java.util.stream.Collector<T,?,MutableList<MutableList<T>>> chunk(int size)
Partitions elements in fixed size chunks.
Examples:
MutableList<MutableList<Integer>> chunks1 = Interval.oneTo(10).stream().collect(Collectors2.chunk(2));
MutableList<MutableList<Integer>> chunks2 = Interval.oneTo(10).reduceInPlace(Collectors2.chunk(2));
Equivalent to using @RichIterable.chunk(int)
LazyIterable<RichIterable<Integer>> chunks = Interval.oneTo(10).chunk(2);
public static <T,S> java.util.stream.Collector<T,?,MutableList<Pair<T,S>>> zip(java.lang.Iterable<S> other)
Returns a MutableList
formed from this stream of elements and another Iterable
by
combining corresponding elements in pairs.
If one of the two Iterable
s is longer than the other, its remaining elements are ignored.
Examples:
MutableList<Pair<Integer, Integer>> zipped1 = Interval.oneTo(10).stream().collect(Collectors2.zip(Interval.oneTo(10)));
MutableList<Pair<Integer, Integer>> zipped2 = Interval.oneTo(10).reduceInPlace(Collectors2.zip(Interval.oneTo(10)));
Equivalent to using @RichIterable.zip(Iterable)
LazyIterable<Pair<Integer, Integer>> zip = Interval.oneTo(10).zip(Interval.oneTo(10));
public static <T> java.util.stream.Collector<T,?,MutableList<ObjectIntPair<T>>> zipWithIndex()
Returns a MutableList
of pairs formed from this stream of elements its indices.
Examples:
MutableList<ObjectIntPair<Integer>> zipWithIndex1 = Interval.oneTo(10).stream().collect(Collectors2.zipWithIndex());
MutableList<ObjectIntPair<Integer>> zipWithIndex2 = Interval.oneTo(10).reduceInPlace(Collectors2.zipWithIndex());
Equivalent to using @RichIterable.zipWithIndex()
LazyIterable<Pair<Integer, Integer>> zipWithIndex = Interval.oneTo(10).zipWithIndex();
public static <T,V> java.util.stream.Collector<T,?,MutableObjectLongMap<V>> sumByInt(Function<? super T,? extends V> groupBy, IntFunction<? super T> function)
Groups and sums the values using the two specified functions.
Examples:
MutableObjectLongMap<Integer> sumBy1 =
Interval.oneTo(10).stream().collect(Collectors2.sumByInt(each -> Integer.valueOf(each % 2), Integer::intValue));
MutableObjectLongMap<Integer> sumBy2 =
Interval.oneTo(10).reduceInPlace(Collectors2.sumByInt(each -> Integer.valueOf(each % 2), Integer::intValue));
Equivalent to using @RichIterable.sumByInt(Function, IntFunction)
ObjectLongMap<Integer> sumBy =
Interval.oneTo(10).sumByInt(each -> Integer.valueOf(each % 2), Integer::intValue));
public static <T,V> java.util.stream.Collector<T,?,MutableObjectLongMap<V>> sumByLong(Function<? super T,? extends V> groupBy, LongFunction<? super T> function)
Groups and sums the values using the two specified functions.
Examples:
MutableObjectLongMap<Long> sumBy1 =
Interval.oneTo(10).stream().collect(Collectors2.sumByLong(each -> Long.valueOf(each % 2), Integer::longValue));
MutableObjectLongMap<Long> sumBy2 =
Interval.oneTo(10).reduceInPlace(Collectors2.sumByLong(each -> Long.valueOf(each % 2), Integer::longValue));
Equivalent to using @RichIterable.sumByLong(Function, LongFunction)
ObjectLongMap<Long> sumBy =
Interval.oneTo(10).sumByLong(each -> Long.valueOf(each % 2), Integer::longValue));
public static <T,V> java.util.stream.Collector<T,?,MutableObjectDoubleMap<V>> sumByFloat(Function<? super T,? extends V> groupBy, FloatFunction<? super T> function)
Groups and sums the values using the two specified functions.
Examples:
MutableObjectDoubleMap<Integer> sumBy1 =
Interval.oneTo(10).stream().collect(Collectors2.sumByFloat(each -> ((int)each % 2), Integer::floatValue));
MutableObjectDoubleMap<Integer> sumBy2 =
Interval.oneTo(10).reduceInPlace(Collectors2.sumByFloat(each -> ((int)each % 2), Integer::floatValue));
Equivalent to using @RichIterable.sumByFloat(Function, FloatFunction)
ObjectDoubleMap<Integer> sumBy =
Interval.oneTo(10).sumByFloat(each -> ((int)each % 2), Integer::floatValue));
public static <T,V> java.util.stream.Collector<T,?,MutableObjectDoubleMap<V>> sumByDouble(Function<? super T,? extends V> groupBy, DoubleFunction<? super T> function)
Groups and sums the values using the two specified functions.
Examples:
MutableObjectDoubleMap<Integer> sumBy1 =
Interval.oneTo(10).stream().collect(Collectors2.sumByDouble(each -> ((int)each % 2), Integer::doubleValue));
MutableObjectDoubleMap<Integer> sumBy2 =
Interval.oneTo(10).reduceInPlace(Collectors2.sumByDouble(each -> ((int)each % 2), Integer::doubleValue));
Equivalent to using @RichIterable.sumByDouble(Function, DoubleFunction)
ObjectDoubleMap<Integer> sumBy =
Interval.oneTo(10).sumByDouble(each -> ((int)each % 2), Integer::doubleValue));
public static <T,V> java.util.stream.Collector<T,?,MutableMap<V,java.math.BigDecimal>> sumByBigDecimal(Function<? super T,? extends V> groupBy, Function<? super T,java.math.BigDecimal> function)
Groups and sums the values using the two specified functions.
Examples:
MutableMap<Integer, BigDecimal> sumBy1 =
Interval.oneTo(10).stream().collect(Collectors2.sumByBigDecimal(each -> (each.intValue() % 2), BigDecimal::new));
MutableMap<Integer, BigDecimal> sumBy2 =
Interval.oneTo(10).reduceInPlace(Collectors2.sumByBigDecimal(each -> (each.intValue() % 2), BigDecimal::new));
Equivalent to using @Iterate.sumByBigDecimal(Iterable, Function, Function)
MutableMap<Integer, BigDecimal> sumBy =
Iterate.sumByBigDecimal(Interval.oneTo(10), each -> (each.intValue() % 2), BigDecimal::new));
public static <T,V> java.util.stream.Collector<T,?,MutableMap<V,java.math.BigInteger>> sumByBigInteger(Function<? super T,? extends V> groupBy, Function<? super T,java.math.BigInteger> function)
Groups and sums the values using the two specified functions.
Examples:
MutableMap<Integer, BigInteger> sumBy1 =
Interval.oneTo(10).stream().collect(Collectors2.sumByBigInteger(each -> (each.intValue() % 2), each -> BigInteger.valueOf(each.longValue())));
MutableMap<Integer, BigInteger> sumBy2 =
Interval.oneTo(10).reduceInPlace(Collectors2.sumByBigInteger(each -> (each.intValue() % 2), each -> BigInteger.valueOf(each.longValue())));
Equivalent to using @Iterate.sumByBigInteger(Iterable, Function, Function)
MutableMap<Integer, BigInteger> sumBy =
Iterate.sumByBigInteger(Interval.oneTo(10), each -> (each.intValue() % 2), each -> BigInteger.valueOf(each.longValue())));
public static <T,R extends java.util.Collection<T>> java.util.stream.Collector<T,?,R> select(Predicate<? super T> predicate, java.util.function.Supplier<R> supplier)
Returns all elements of the stream that return true when evaluating the predicate. This method is also commonly called filter. The new collection is created as the result of evaluating the provided Supplier.
Examples:
MutableList<Integer> evens1 =
Interval.oneTo(10).stream().collect(Collectors2.select(e -> e % 2 == 0, Lists.mutable::empty));
MutableList<Integer> evens2 =
Interval.oneTo(10).reduceInPlace(Collectors2.select(e -> e % 2 == 0, Lists.mutable::empty));
Equivalent to using @RichIterable.select(Predicate, Collection)
MutableList<Integer> evens = Interval.oneTo(10).select(e -> e % 2 == 0, Lists.mutable.empty());
public static <T,P,R extends java.util.Collection<T>> java.util.stream.Collector<T,?,R> selectWith(Predicate2<? super T,? super P> predicate, P parameter, java.util.function.Supplier<R> supplier)
Returns all elements of the stream that return true when evaluating the predicate with the parameter. The new collection is created as the result of evaluating the provided Supplier.
Examples:
MutableList<Integer> evens1 =
Interval.oneTo(10).stream().collect(Collectors2.selectWith((e, p) -> e % p == 0, 2, Lists.mutable::empty));
MutableList<Integer> evens2 =
Interval.oneTo(10).reduceInPlace(Collectors2.selectWith((e, p) -> e % p == 0, 2, Lists.mutable::empty));
Equivalent to using @RichIterable.selectWith(Predicate2, Object, Collection)
MutableList<Integer> evens = Interval.oneTo(10).selectWith((e, p) -> e % p == 0, 2, Lists.mutable.empty());
public static <T,R extends java.util.Collection<T>> java.util.stream.Collector<T,?,R> reject(Predicate<? super T> predicate, java.util.function.Supplier<R> supplier)
Returns all elements of the stream that return false when evaluating the predicate. This method is also commonly called filterNot. The new collection is created as the result of evaluating the provided Supplier.
Examples:
MutableList<Integer> odds1 =
Interval.oneTo(10).stream().collect(Collectors2.reject(e -> e % 2 == 0, Lists.mutable::empty));
MutableList<Integer> odds2 =
Interval.oneTo(10).reduceInPlace(Collectors2.reject(e -> e % 2 == 0, Lists.mutable::empty));
Equivalent to using @RichIterable.reject(Predicate, Collection)
MutableList<Integer> odds = Interval.oneTo(10).reject(e -> e % 2 == 0, Lists.mutable.empty());
public static <T,P,R extends java.util.Collection<T>> java.util.stream.Collector<T,?,R> rejectWith(Predicate2<? super T,? super P> predicate, P parameter, java.util.function.Supplier<R> supplier)
Returns all elements of the stream that return false when evaluating the predicate with the parameter. The new collection is created as the result of evaluating the provided Supplier.
Examples:
MutableList<Integer> odds1 =
Interval.oneTo(10).stream().collect(Collectors2.rejectWith((e, p) -> e % p == 0, 2, Lists.mutable::empty));
MutableList<Integer> odds2 =
Interval.oneTo(10).reduceInPlace(Collectors2.rejectWith((e, p) -> e % p == 0, 2, Lists.mutable::empty));
Equivalent to using @RichIterable.rejectWith(Predicate2, Object, Collection)
MutableList<Integer> odds = Interval.oneTo(10).rejectWith((e, p) -> e % p == 0, 2, Lists.mutable.empty());
public static <T,R extends PartitionMutableCollection<T>> java.util.stream.Collector<T,?,R> partition(Predicate<? super T> predicate, java.util.function.Supplier<R> supplier)
Returns all elements of the stream split into a PartitionMutableCollection after evaluating the predicate. The new PartitionMutableCollection is created as the result of evaluating the provided Supplier.
Examples:
PartitionMutableList<Integer> evensAndOdds1 =
Interval.oneTo(10).stream().collect(Collectors2.partition(e -> e % 2 == 0, PartitionFastList::new));
PartitionMutableList<Integer> evensAndOdds2 =
Interval.oneTo(10).reduceInPlace(Collectors2.partition(e -> e % 2 == 0, PartitionFastList::new));
Equivalent to using @RichIterable.partition(Predicate)
PartitionMutableList<Integer> evensAndOdds = Interval.oneTo(10).partition(e -> e % 2 == 0);
public static <T,P,R extends PartitionMutableCollection<T>> java.util.stream.Collector<T,?,R> partitionWith(Predicate2<? super T,? super P> predicate, P parameter, java.util.function.Supplier<R> supplier)
Returns all elements of the stream split into a PartitionMutableCollection after evaluating the predicate. The new PartitionMutableCollection is created as the result of evaluating the provided Supplier.
Examples:
PartitionMutableList<Integer> evensAndOdds1 =
Interval.oneTo(10).stream().collect(Collectors2.partitionWith((e, p) -> e % p == 0, 2, PartitionFastList::new));
PartitionMutableList<Integer> evensAndOdds2 =
Interval.oneTo(10).reduceInPlace(Collectors2.partitionWith((e, p) -> e % p == 0, 2, PartitionFastList::new));
Equivalent to using @RichIterable.partitionWith(Predicate2, Object)
PartitionMutableList<Integer> evensAndOdds = Interval.oneTo(10).partitionWith((e, p) -> e % p == 0, 2);
public static <T,V,R extends java.util.Collection<V>> java.util.stream.Collector<T,?,R> collect(Function<? super T,? extends V> function, java.util.function.Supplier<R> supplier)
Returns a new collection with the results of applying the specified function on each element of the source collection. This method is also commonly called transform or map. The new collection is created as the result of evaluating the provided Supplier.
Examples:
MutableList<String> collect1 =
Interval.oneTo(10).stream().collect(Collectors2.collect(Object::toString, Lists.mutable::empty));
MutableList<String> collect2 =
Interval.oneTo(10).reduceInPlace(Collectors2.collect(Object::toString, Lists.mutable::empty));
Equivalent to using @RichIterable.collect(Function, Collection)
MutableList<String> collect = Interval.oneTo(10).collect(Object::toString, Lists.mutable.empty());
public static <T,V,R extends java.util.Collection<V>> java.util.stream.Collector<T,?,R> flatCollect(Function<? super T,? extends java.lang.Iterable<V>> function, java.util.function.Supplier<R> supplier)
flatCollect
is a special case of collect(Function, Supplier)
. With collect
,
when the Function
returns a collection, the result is a collection of collections. flatCollect
outputs
a single "flattened" collection instead. This method is commonly called flatMap.
Example:
List<MutableList<String>> lists =
Lists.mutable.with(
Lists.mutable.with("a", "b"),
Lists.mutable.with("c", "d"),
Lists.mutable.with("e"));
MutableList<String> flattened =
lists.stream().collect(Collectors2.flatCollect(l -> l, Lists.mutable::empty));
Assert.assertEquals(Lists.mutable.with("a", "b", "c", "d", "e"), flattened);
public static <T,P,V,R extends java.util.Collection<V>> java.util.stream.Collector<T,?,R> collectWith(Function2<? super T,? super P,? extends V> function, P parameter, java.util.function.Supplier<R> supplier)
Returns a new collection with the results of applying the specified function on each element of the source collection with the specified parameter. This method is also commonly called transform or map. The new collection is created as the result of evaluating the provided Supplier.
Examples:
MutableList<Integer> collect1 =
Interval.oneTo(10).stream().collect(Collectors2.collectWith(Integer::sum, Integer.valueOf(10), Lists.mutable::empty));
MutableList<Integer> collect2 =
Interval.oneTo(10).reduceInPlace(Collectors2.collectWith(Integer::sum, Integer.valueOf(10), Lists.mutable::empty));
Equivalent to using @RichIterable.collectWith(Function2, Object, Collection)
MutableList<Integer> collect = Interval.oneTo(10).collectWith(Integer::sum, Integer.valueOf(10), Lists.mutable.empty());
public static <T,R extends MutableBooleanCollection> java.util.stream.Collector<T,?,R> collectBoolean(BooleanFunction<? super T> function, java.util.function.Supplier<R> supplier)
Returns a new MutableBooleanCollection with the results of applying the specified BooleanFunction on each element of the source. The new collection is created as the result of evaluating the provided Supplier.
Examples:
MutableBooleanList collect1 =
Interval.oneTo(10).stream().collect(Collectors2.collectBoolean(each -> each % 2 == 0, BooleanLists.mutable::empty));
MutableBooleanList collect2 =
Interval.oneTo(10).reduceInPlace(Collectors2.collectBoolean(each -> each % 2 == 0, BooleanLists.mutable::empty));
Equivalent to using @RichIterable.collectBoolean(BooleanFunction, MutableBooleanCollection)
MutableBooleanList collect =
Interval.oneTo(10).collectBoolean(each -> each % 2 == 0, BooleanLists.mutable.empty());
public static <T,R extends MutableByteCollection> java.util.stream.Collector<T,?,R> collectByte(ByteFunction<? super T> function, java.util.function.Supplier<R> supplier)
Returns a new MutableByteCollection with the results of applying the specified ByteFunction on each element of the source. The new collection is created as the result of evaluating the provided Supplier.
Examples:
MutableByteList collect1 =
Interval.oneTo(10).stream().collect(Collectors2.collectByte(each -> (byte) (each % Byte.MAX_VALUE), ByteLists.mutable::empty));
MutableByteList collect2 =
Interval.oneTo(10).reduceInPlace(Collectors2.collectByte(each -> (byte) (each % Byte.MAX_VALUE), ByteLists.mutable::empty));
Equivalent to using @RichIterable.collectByte(ByteFunction, MutableByteCollection)
MutableByteList collect =
Interval.oneTo(10).collectByte(each -> (byte) (each % Byte.MAX_VALUE), ByteLists.mutable.empty());
public static <T,R extends MutableCharCollection> java.util.stream.Collector<T,?,R> collectChar(CharFunction<? super T> function, java.util.function.Supplier<R> supplier)
Returns a new MutableCharCollection with the results of applying the specified CharFunction on each element of the source. The new collection is created as the result of evaluating the provided Supplier.
Examples:
MutableCharList collect1 =
Interval.oneTo(10).stream().collect(Collectors2.collectChar(each -> (char) (each % Character.MAX_VALUE), CharLists.mutable::empty));
MutableCharList collect2 =
Interval.oneTo(10).reduceInPlace(Collectors2.collectChar(each -> (char) (each % Character.MAX_VALUE), CharLists.mutable::empty));
Equivalent to using @RichIterable.collectChar(CharFunction, MutableCharCollection)
MutableCharList collect =
Interval.oneTo(10).collectChar(each -> (char) (each % Character.MAX_VALUE), CharLists.mutable.empty());
public static <T,R extends MutableShortCollection> java.util.stream.Collector<T,?,R> collectShort(ShortFunction<? super T> function, java.util.function.Supplier<R> supplier)
Returns a new MutableShortCollection with the results of applying the specified ShortFunction on each element of the source. The new collection is created as the result of evaluating the provided Supplier.
Examples:
MutableShortList collect1 =
Interval.oneTo(10).stream().collect(Collectors2.collectShort(each -> (short) (each % Short.MAX_VALUE), ShortLists.mutable::empty));
MutableShortList collect2 =
Interval.oneTo(10).reduceInPlace(Collectors2.collectShort(each -> (short) (each % Short.MAX_VALUE), ShortLists.mutable::empty));
Equivalent to using @RichIterable.collectShort(ShortFunction, MutableShortCollection)
MutableShortList collect =
Interval.oneTo(10).collectShort(each -> (short) (each % Short.MAX_VALUE), ShortLists.mutable.empty());
public static <T,R extends MutableIntCollection> java.util.stream.Collector<T,?,R> collectInt(IntFunction<? super T> function, java.util.function.Supplier<R> supplier)
Returns a new MutableIntCollection with the results of applying the specified IntFunction on each element of the source. The new collection is created as the result of evaluating the provided Supplier.
Examples:
MutableIntList collect1 =
Interval.oneTo(10).stream().collect(Collectors2.collectInt(each -> each, IntLists.mutable::empty));
MutableIntList collect2 =
Interval.oneTo(10).reduceInPlace(Collectors2.collectInt(each -> each, IntLists.mutable::empty));
Equivalent to using @RichIterable.collectInt(IntFunction, MutableIntCollection)
MutableIntList collect =
Interval.oneTo(10).collectInt(each -> each, IntLists.mutable.empty());
public static <T,R extends MutableFloatCollection> java.util.stream.Collector<T,?,R> collectFloat(FloatFunction<? super T> function, java.util.function.Supplier<R> supplier)
Returns a new MutableFloatCollection with the results of applying the specified FloatFunction on each element of the source. The new collection is created as the result of evaluating the provided Supplier.
Examples:
MutableFloatList collect1 =
Interval.oneTo(10).stream().collect(Collectors2.collectFloat(each -> (float) each, FloatLists.mutable::empty));
MutableFloatList collect2 =
Interval.oneTo(10).reduceInPlace(Collectors2.collectFloat(each -> (float) each, FloatLists.mutable::empty));
Equivalent to using @RichIterable.collectFloat(FloatFunction, MutableFloatCollection)
MutableFloatList collect =
Interval.oneTo(10).collectFloat(each -> (float) each, FloatLists.mutable.empty());
public static <T,R extends MutableLongCollection> java.util.stream.Collector<T,?,R> collectLong(LongFunction<? super T> function, java.util.function.Supplier<R> supplier)
Returns a new MutableLongCollection with the results of applying the specified LongFunction on each element of the source. The new collection is created as the result of evaluating the provided Supplier.
Examples:
MutableLongList collect1 =
Interval.oneTo(10).stream().collect(Collectors2.collectLong(each -> (long) each, LongLists.mutable::empty));
MutableLongList collect2 =
Interval.oneTo(10).reduceInPlace(Collectors2.collectLong(each -> (long) each, LongLists.mutable::empty));
Equivalent to using @RichIterable.collectLong(LongFunction, MutableLongCollection)
MutableLongList collect =
Interval.oneTo(10).collectLong(each -> (long) each, LongLists.mutable.empty());
public static <T,R extends MutableDoubleCollection> java.util.stream.Collector<T,?,R> collectDouble(DoubleFunction<? super T> function, java.util.function.Supplier<R> supplier)
Returns a new MutableDoubleCollection with the results of applying the specified DoubleFunction on each element of the source. The new collection is created as the result of evaluating the provided Supplier.
Examples:
MutableDoubleList collect1 =
Interval.oneTo(10).stream().collect(Collectors2.collectDouble(each -> (double) each, DoubleLists.mutable::empty));
MutableDoubleList collect2 =
Interval.oneTo(10).reduceInPlace(Collectors2.collectDouble(each -> (double) each, DoubleLists.mutable::empty));
Equivalent to using @RichIterable.collectDouble(DoubleFunction, MutableDoubleCollection)
MutableDoubleList collect =
Interval.oneTo(10).collectDouble(each -> (double) each, DoubleLists.mutable.empty());
public static <T> java.util.stream.Collector<T,?,SummaryStatistics<T>> summarizing(ImmutableList<IntFunction<? super T>> intFunctions, ImmutableList<LongFunction<? super T>> longFunctions, ImmutableList<DoubleFunction<? super T>> doubleFunctions)
public static <T> java.util.stream.Collector<T,?,BigDecimalSummaryStatistics> summarizingBigDecimal(Function<? super T,java.math.BigDecimal> function)
public static <T> java.util.stream.Collector<T,?,BigIntegerSummaryStatistics> summarizingBigInteger(Function<? super T,java.math.BigInteger> function)
public static <T> java.util.stream.Collector<T,?,java.math.BigDecimal> summingBigDecimal(Function<? super T,java.math.BigDecimal> function)
public static <T> java.util.stream.Collector<T,?,java.math.BigInteger> summingBigInteger(Function<? super T,java.math.BigInteger> function)
Copyright © 2004–2018. All rights reserved.