A - the mutable accumulation type of the reduction operation (often
hidden as an implementation detail)R - the result type of the reduction operationpublic interface IntCollector<A,R>
Collector specialized to work with primitive int.IntStreamEx.collect(IntCollector)Collector.Characteristics| Modifier and Type | Method and Description |
|---|---|
default BiConsumer<A,Integer> |
accumulator()
A function that folds a value into a mutable result container.
|
default <RR> IntCollector<A,RR> |
andThen(Function<R,RR> finisher)
Adapts this collector to perform an additional finishing transformation.
|
static IntCollector<?,OptionalDouble> |
averaging()
Returns an
IntCollector that produces the arithmetic mean of the
input elements or an empty optional if no elements are collected. |
default BinaryOperator<A> |
combiner()
A function that accepts two partial results and combines them returning
either existing partial result or new one.
|
static IntCollector<?,Long> |
counting()
Returns an
IntCollector that counts the number of input elements
and returns the result as Long. |
static IntCollector<?,Integer> |
countingInt()
Returns an
IntCollector that counts the number of input elements
and returns the result as Integer. |
static <K> IntCollector<?,Map<K,int[]>> |
groupingBy(IntFunction<? extends K> classifier)
Returns an
IntCollector implementing a "group by" operation on
input numbers, grouping them according to a classification function, and
returning the results in a Map. |
static <K,D,A> IntCollector<?,Map<K,D>> |
groupingBy(IntFunction<? extends K> classifier,
IntCollector<A,D> downstream)
Returns an
IntCollector implementing a cascaded "group by"
operation on input numbers, grouping them according to a classification
function, and then performing a reduction operation on the values
associated with a given key using the specified downstream
IntCollector. |
static <K,D,A,M extends Map<K,D>> |
groupingBy(IntFunction<? extends K> classifier,
Supplier<M> mapFactory,
IntCollector<A,D> downstream)
Returns an
IntCollector implementing a cascaded "group by"
operation on input numbers, grouping them according to a classification
function, and then performing a reduction operation on the values
associated with a given key using the specified downstream
IntCollector. |
ObjIntConsumer<A> |
intAccumulator()
A function that folds a value into a mutable result container.
|
static IntCollector<?,String> |
joining(CharSequence delimiter)
Returns an
IntCollector that converts the input numbers to
strings and concatenates them, separated by the specified delimiter, in
encounter order. |
static IntCollector<?,String> |
joining(CharSequence delimiter,
CharSequence prefix,
CharSequence suffix)
Returns an
IntCollector that converts the input numbers to
strings and concatenates them, separated by the specified delimiter, with
the specified prefix and suffix, in encounter order. |
static <A,R> IntCollector<?,R> |
mapping(IntUnaryOperator mapper,
IntCollector<A,R> downstream)
Adapts an
IntCollector to another one by applying a mapping
function to each input element before accumulation. |
static <U,A,R> IntCollector<?,R> |
mappingToObj(IntFunction<U> mapper,
Collector<U,A,R> downstream)
Adapts a
Collector accepting elements of type U to an
IntCollector by applying a mapping function to each input element
before accumulation. |
static IntCollector<?,OptionalInt> |
max()
Returns an
IntCollector that produces the maximal element,
described as an OptionalInt. |
BiConsumer<A,A> |
merger()
A function that merges the second partial result into the first partial
result.
|
static IntCollector<?,OptionalInt> |
min()
Returns an
IntCollector that produces the minimal element,
described as an OptionalInt. |
static <A,R> IntCollector<?,R> |
of(Collector<Integer,A,R> collector)
Adapts a
Collector which accepts elements of type Integer
to an IntCollector. |
static <A,R> IntCollector<A,R> |
of(Supplier<A> supplier,
ObjIntConsumer<A> intAccumulator,
BiConsumer<A,A> merger,
Function<A,R> finisher)
Returns a new
IntCollector described by the given
supplier, accumulator, merger, and
finisher functions. |
static <R> IntCollector<R,R> |
of(Supplier<R> supplier,
ObjIntConsumer<R> intAccumulator,
BiConsumer<R,R> merger)
Returns a new
IntCollector described by the given
supplier, accumulator, and merger functions. |
static IntCollector<?,Map<Boolean,int[]>> |
partitioningBy(IntPredicate predicate)
Returns an
IntCollector which partitions the input elements
according to an IntPredicate, and organizes them into a
Map<Boolean, int[]>. |
static <A,D> IntCollector<?,Map<Boolean,D>> |
partitioningBy(IntPredicate predicate,
IntCollector<A,D> downstream)
Returns an
IntCollector which partitions the input numbers
according to an IntPredicate, reduces the values in each
partition according to another IntCollector, and organizes them
into a Map<Boolean, D> whose values are the result of the
downstream reduction. |
static IntCollector<?,OptionalInt> |
reducing(IntBinaryOperator op)
Returns an
IntCollector which performs a reduction of its input
numbers under a specified IntBinaryOperator. |
static IntCollector<?,Integer> |
reducing(int identity,
IntBinaryOperator op)
Returns an
IntCollector which performs a reduction of its input
numbers under a specified IntBinaryOperator using the provided
identity. |
static IntCollector<?,IntSummaryStatistics> |
summarizing()
Returns an
IntCollector which returns summary statistics for the
input elements. |
static IntCollector<?,Integer> |
summing()
Returns an
IntCollector that produces the sum of the input
elements. |
static IntCollector<?,int[]> |
toArray()
Returns an
IntCollector that produces the array of the input
elements. |
static IntCollector<?,BitSet> |
toBitSet()
Returns an
IntCollector that produces the BitSet of the
input elements. |
static IntCollector<?,boolean[]> |
toBooleanArray(IntPredicate predicate)
Returns an
IntCollector which produces a boolean array containing
the results of applying the given predicate to the input elements, in
encounter order. |
static IntCollector<?,byte[]> |
toByteArray()
Returns an
IntCollector that produces the byte[] array of
the input elements converting them via (byte) casting. |
static IntCollector<?,char[]> |
toCharArray()
Returns an
IntCollector that produces the char[] array of
the input elements converting them via (char) casting. |
static IntCollector<?,short[]> |
toShortArray()
Returns an
IntCollector that produces the short[] array
of the input elements converting them via (short) casting. |
ObjIntConsumer<A> intAccumulator()
default BiConsumer<A,Integer> accumulator()
intAccumulator() on unboxed
value.default <RR> IntCollector<A,RR> andThen(Function<R,RR> finisher)
RR - result type of the resulting collectorfinisher - a function to be applied to the final result of this
collectorstatic <R> IntCollector<R,R> of(Supplier<R> supplier, ObjIntConsumer<R> intAccumulator, BiConsumer<R,R> merger)
IntCollector described by the given
supplier, accumulator, and merger functions. The
resulting IntCollector has the
Collector.Characteristics.IDENTITY_FINISH characteristic.R - The type of intermediate accumulation result, and final
result, for the new collectorsupplier - The supplier function for the new collectorintAccumulator - The intAccumulator function for the new collectormerger - The merger function for the new collectorIntCollectorstatic <A,R> IntCollector<?,R> of(Collector<Integer,A,R> collector)
Collector which accepts elements of type Integer
to an IntCollector.A - The intermediate accumulation type of the collectorR - The final result type of the collectorcollector - a Collector to adaptIntCollector which behaves in the same way as input
collector.static <A,R> IntCollector<A,R> of(Supplier<A> supplier, ObjIntConsumer<A> intAccumulator, BiConsumer<A,A> merger, Function<A,R> finisher)
IntCollector described by the given
supplier, accumulator, merger, and
finisher functions.A - The intermediate accumulation type of the new collectorR - The final result type of the new collectorsupplier - The supplier function for the new collectorintAccumulator - The intAccumulator function for the new collectormerger - The merger function for the new collectorfinisher - The finisher function for the new collectorIntCollectorstatic IntCollector<?,String> joining(CharSequence delimiter, CharSequence prefix, CharSequence suffix)
IntCollector that converts the input numbers to
strings and concatenates them, separated by the specified delimiter, with
the specified prefix and suffix, in encounter order.delimiter - the delimiter to be used between each elementprefix - the sequence of characters to be used at the beginning of
the joined resultsuffix - the sequence of characters to be used at the end of the
joined resultIntCollector which concatenates the input numbers,
separated by the specified delimiter, in encounter orderstatic IntCollector<?,String> joining(CharSequence delimiter)
IntCollector that converts the input numbers to
strings and concatenates them, separated by the specified delimiter, in
encounter order.delimiter - the delimiter to be used between each elementIntCollector which concatenates the input numbers,
separated by the specified delimiter, in encounter orderstatic IntCollector<?,Long> counting()
IntCollector that counts the number of input elements
and returns the result as Long. If no elements are present, the
result is 0.IntCollector that counts the input elementsstatic IntCollector<?,Integer> countingInt()
IntCollector that counts the number of input elements
and returns the result as Integer. If no elements are present,
the result is 0.IntCollector that counts the input elementsstatic IntCollector<?,Integer> summing()
IntCollector that produces the sum of the input
elements. If no elements are present, the result is 0.IntCollector that produces the sum of the input
elementsstatic IntCollector<?,OptionalDouble> averaging()
IntCollector that produces the arithmetic mean of the
input elements or an empty optional if no elements are collected.
Note that unlike IntStream.average(),
Collectors.averagingInt(java.util.function.ToIntFunction) and
IntSummaryStatistics.getAverage() this collector does not
overflow if an intermediate sum exceeds Long.MAX_VALUE.
IntCollector that produces the arithmetic mean of the
input elementsstatic IntCollector<?,OptionalInt> min()
IntCollector that produces the minimal element,
described as an OptionalInt. If no elements are present, the
result is an empty OptionalInt.IntCollector that produces the minimal element.static IntCollector<?,OptionalInt> max()
IntCollector that produces the maximal element,
described as an OptionalInt. If no elements are present, the
result is an empty OptionalInt.IntCollector that produces the maximal element.static <A,R> IntCollector<?,R> mapping(IntUnaryOperator mapper, IntCollector<A,R> downstream)
IntCollector to another one by applying a mapping
function to each input element before accumulation.A - intermediate accumulation type of the downstream collectorR - result type of collectormapper - a function to be applied to the input elementsdownstream - a collector which will accept mapped valuesstatic <U,A,R> IntCollector<?,R> mappingToObj(IntFunction<U> mapper, Collector<U,A,R> downstream)
Collector accepting elements of type U to an
IntCollector by applying a mapping function to each input element
before accumulation.U - type of elements accepted by downstream collectorA - intermediate accumulation type of the downstream collectorR - result type of collectormapper - a function to be applied to the input elementsdownstream - a collector which will accept mapped valuesstatic IntCollector<?,OptionalInt> reducing(IntBinaryOperator op)
IntCollector which performs a reduction of its input
numbers under a specified IntBinaryOperator. The result is
described as an OptionalInt.op - an IntBinaryOperator used to reduce the input numbersIntCollector which implements the reduction operation.static IntCollector<?,Integer> reducing(int identity, IntBinaryOperator op)
IntCollector which performs a reduction of its input
numbers under a specified IntBinaryOperator using the provided
identity.identity - the identity value for the reduction (also, the value
that is returned when there are no input elements)op - an IntBinaryOperator used to reduce the input numbersIntCollector which implements the reduction operationstatic IntCollector<?,IntSummaryStatistics> summarizing()
IntCollector which returns summary statistics for the
input elements.IntCollector implementing the summary-statistics
reductionstatic IntCollector<?,Map<Boolean,int[]>> partitioningBy(IntPredicate predicate)
IntCollector which partitions the input elements
according to an IntPredicate, and organizes them into a
Map<Boolean, int[]>.
There are no guarantees on the type, mutability, serializability, or
thread-safety of the Map returned.predicate - a predicate used for classifying input elementsIntCollector implementing the partitioning operationstatic <A,D> IntCollector<?,Map<Boolean,D>> partitioningBy(IntPredicate predicate, IntCollector<A,D> downstream)
IntCollector which partitions the input numbers
according to an IntPredicate, reduces the values in each
partition according to another IntCollector, and organizes them
into a Map<Boolean, D> whose values are the result of the
downstream reduction.
There are no guarantees on the type, mutability, serializability, or
thread-safety of the Map returned.
A - the intermediate accumulation type of the downstream collectorD - the result type of the downstream reductionpredicate - a predicate used for classifying input elementsdownstream - an IntCollector implementing the downstream
reductionIntCollector implementing the cascaded partitioning
operationstatic <K> IntCollector<?,Map<K,int[]>> groupingBy(IntFunction<? extends K> classifier)
IntCollector implementing a "group by" operation on
input numbers, grouping them according to a classification function, and
returning the results in a Map.
The classification function maps elements to some key type K. The
collector produces a Map<K, int[]> whose keys are the values
resulting from applying the classification function to the input numbers,
and whose corresponding values are arrays containing the input numbers
which map to the associated key under the classification function.
There are no guarantees on the type, mutability, serializability, or
thread-safety of the Map objects returned.
K - the type of the keysclassifier - the classifier function mapping input elements to keysIntCollector implementing the group-by operationstatic <K,D,A> IntCollector<?,Map<K,D>> groupingBy(IntFunction<? extends K> classifier, IntCollector<A,D> downstream)
IntCollector implementing a cascaded "group by"
operation on input numbers, grouping them according to a classification
function, and then performing a reduction operation on the values
associated with a given key using the specified downstream
IntCollector.
The classification function maps elements to some key type K. The
downstream collector produces a result of type D. The resulting
collector produces a Map<K, D>.
There are no guarantees on the type, mutability, serializability, or
thread-safety of the Map returned.
K - the type of the keysA - the intermediate accumulation type of the downstream collectorD - the result type of the downstream reductionclassifier - a classifier function mapping input elements to keysdownstream - an IntCollector implementing the downstream
reductionIntCollector implementing the cascaded group-by
operationstatic <K,D,A,M extends Map<K,D>> IntCollector<?,M> groupingBy(IntFunction<? extends K> classifier, Supplier<M> mapFactory, IntCollector<A,D> downstream)
IntCollector implementing a cascaded "group by"
operation on input numbers, grouping them according to a classification
function, and then performing a reduction operation on the values
associated with a given key using the specified downstream
IntCollector. The Map produced by the Collector is
created with the supplied factory function.
The classification function maps elements to some key type K. The
downstream collector produces a result of type D. The resulting
collector produces a Map<K, D>.
K - the type of the keysA - the intermediate accumulation type of the downstream collectorD - the result type of the downstream reductionM - the type of the resulting Mapclassifier - a classifier function mapping input elements to keysdownstream - an IntCollector implementing the downstream
reductionmapFactory - a function which, when called, produces a new empty
Map of the desired typeIntCollector implementing the cascaded group-by
operationstatic IntCollector<?,BitSet> toBitSet()
IntCollector that produces the BitSet of the
input elements.IntCollector that produces the BitSet of the
input elementsstatic IntCollector<?,int[]> toArray()
IntCollector that produces the array of the input
elements. If no elements are present, the result is an empty array.IntCollector that produces the array of the input
elementsstatic IntCollector<?,byte[]> toByteArray()
IntCollector that produces the byte[] array of
the input elements converting them via (byte) casting. If no
elements are present, the result is an empty array.IntCollector that produces the byte[] array of
the input elementsstatic IntCollector<?,char[]> toCharArray()
IntCollector that produces the char[] array of
the input elements converting them via (char) casting. If no
elements are present, the result is an empty array.IntCollector that produces the char[] array of
the input elementsstatic IntCollector<?,short[]> toShortArray()
IntCollector that produces the short[] array
of the input elements converting them via (short) casting. If no
elements are present, the result is an empty array.IntCollector that produces the short[] array
of the input elementsstatic IntCollector<?,boolean[]> toBooleanArray(IntPredicate predicate)
IntCollector which produces a boolean array containing
the results of applying the given predicate to the input elements, in
encounter order.predicate - a non-interfering, stateless predicate to apply to each
input element. The result values of this predicate are collected
to the resulting boolean array.IntCollector which collects the results of the
predicate function to the boolean array, in encounter order.BiConsumer<A,A> merger()
default BinaryOperator<A> combiner()
merger() and returns the
first partial result.Copyright © 2017. All rights reserved.