Interface DoubleCollector<A,R>
- Type Parameters:
A- the mutable accumulation type of the reduction operation (often hidden as an implementation detail)R- the result type of the reduction operation
- All Superinterfaces:
Collector<Double,A, R>, MergingCollector<Double, A, R>
- All Known Implementing Classes:
Internals.DoubleCollectorImpl
Collector specialized to work with primitive double.- Since:
- 0.3.0
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from interface Collector
Collector.Characteristics -
Method Summary
Modifier and TypeMethodDescriptiondefault BiConsumer<A, Double> A function that folds a value into a mutable result container.default <RR> DoubleCollector<A, RR> Adapts this collector to perform an additional finishing transformation.static DoubleCollector<?, OptionalDouble> Returns aDoubleCollectorthat produces the arithmetic mean of the input elements or an empty optional if no elements are collected.static DoubleCollector<?, Long> counting()Returns aDoubleCollectorthat counts the number of input elements and returns the result asLong.static DoubleCollector<?, Integer> Returns anDoubleCollectorthat counts the number of input elements and returns the result asInteger.A function that folds a value into a mutable result container.static <K> DoubleCollector<?, Map<K, double[]>> groupingBy(DoubleFunction<? extends K> classifier) Returns aDoubleCollectorimplementing a "group by" operation on input numbers, grouping them according to a classification function, and returning the results in aMap.static <K, D, A, M extends Map<K,D>>
DoubleCollector<?, M> groupingBy(DoubleFunction<? extends K> classifier, Supplier<M> mapFactory, DoubleCollector<A, D> downstream) Returns aDoubleCollectorimplementing 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 downstreamIntCollector.static <K,D, A> DoubleCollector <?, Map<K, D>> groupingBy(DoubleFunction<? extends K> classifier, DoubleCollector<A, D> downstream) Returns aDoubleCollectorimplementing 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 downstreamIntCollector.static DoubleCollector<?, String> joining(CharSequence delimiter) Returns aDoubleCollectorthat converts the input numbers to strings and concatenates them, separated by the specified delimiter, in encounter order.static DoubleCollector<?, String> joining(CharSequence delimiter, CharSequence prefix, CharSequence suffix) Returns aDoubleCollectorthat 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> DoubleCollector <?, R> mapping(DoubleUnaryOperator mapper, DoubleCollector<A, R> downstream) Adapts aDoubleCollectorto another one by applying a mapping function to each input element before accumulation.static <U,A, R> DoubleCollector <?, R> mappingToObj(DoubleFunction<U> mapper, Collector<U, A, R> downstream) Adapts aCollectoraccepting elements of typeUto aDoubleCollectorby applying a mapping function to each input element before accumulation.static DoubleCollector<?, OptionalDouble> max()Returns aDoubleCollectorthat produces the maximal element, described as anOptionalDouble.static DoubleCollector<?, OptionalDouble> min()Returns aDoubleCollectorthat produces the minimal element, described as anOptionalDouble.static <A,R> DoubleCollector <A, R> of(Supplier<A> supplier, ObjDoubleConsumer<A> doubleAccumulator, BiConsumer<A, A> merger, Function<A, R> finisher) Returns a newDoubleCollectordescribed by the givensupplier,accumulator,merger, andfinisherfunctions.static <R> DoubleCollector<R, R> of(Supplier<R> supplier, ObjDoubleConsumer<R> doubleAccumulator, BiConsumer<R, R> merger) Returns a newDoubleCollectordescribed by the givensupplier,accumulator, andmergerfunctions.static <A,R> DoubleCollector <?, R> Adapts aCollectorwhich accepts elements of typeDoubleto aDoubleCollector.static DoubleCollector<?, Map<Boolean, double[]>> partitioningBy(DoublePredicate predicate) Returns aDoubleCollectorwhich partitions the input elements according to aDoublePredicate, and organizes them into aMap<Boolean, double[]>.static <A,D> DoubleCollector <?, Map<Boolean, D>> partitioningBy(DoublePredicate predicate, DoubleCollector<A, D> downstream) Returns aDoubleCollectorwhich partitions the input numbers according to aDoublePredicate, reduces the values in each partition according to anotherIntCollector, and organizes them into aMap<Boolean, D>whose values are the result of the downstream reduction.static DoubleCollector<?, Double> reducing(double identity, DoubleBinaryOperator op) Returns aDoubleCollectorwhich performs a reduction of its input numbers under a specifiedIntBinaryOperatorusing the provided identity.static DoubleCollector<?, OptionalDouble> Returns aDoubleCollectorwhich performs a reduction of its input numbers under a specifiedDoubleBinaryOperator.static DoubleCollector<?, DoubleSummaryStatistics> Returns aDoubleCollectorwhich returns summary statistics for the input elements.static DoubleCollector<?, Double> summing()Returns aDoubleCollectorthat produces the sum of the input elements.static DoubleCollector<?, double[]> toArray()Returns aDoubleCollectorthat produces the array of the input elements.static DoubleCollector<?, boolean[]> toBooleanArray(DoublePredicate predicate) Returns aDoubleCollectorwhich produces a boolean array containing the results of applying the given predicate to the input elements, in encounter order.static DoubleCollector<?, float[]> Returns aDoubleCollectorthat produces thefloat[]array of the input elements converting them via(float)casting.Methods inherited from interface Collector
characteristics, finisher, supplierMethods inherited from interface MergingCollector
combiner, merger
-
Method Details
-
doubleAccumulator
ObjDoubleConsumer<A> doubleAccumulator()A function that folds a value into a mutable result container.- Returns:
- a function which folds a value into a mutable result container
-
accumulator
A function that folds a value into a mutable result container.The default implementation calls
doubleAccumulator()on unboxed value.- Specified by:
accumulatorin interfaceCollector<Double,A, R> - Returns:
- a function which folds a value into a mutable result container
-
andThen
Adapts this collector to perform an additional finishing transformation.- Type Parameters:
RR- result type of the resulting collector- Parameters:
finisher- a function to be applied to the final result of this collector- Returns:
- a collector which performs the action of this collector, followed by an additional finishing step
- Since:
- 0.3.7
-
of
static <R> DoubleCollector<R,R> of(Supplier<R> supplier, ObjDoubleConsumer<R> doubleAccumulator, BiConsumer<R, R> merger) Returns a newDoubleCollectordescribed by the givensupplier,accumulator, andmergerfunctions. The resultingDoubleCollectorhas theCollector.Characteristics.IDENTITY_FINISHcharacteristic.- Type Parameters:
R- The type of intermediate accumulation result, and final result, for the new collector- Parameters:
supplier- The supplier function for the new collectordoubleAccumulator- The doubleAccumulator function for the new collectormerger- The merger function for the new collector- Returns:
- the new
DoubleCollector
-
of
Adapts aCollectorwhich accepts elements of typeDoubleto aDoubleCollector.- Type Parameters:
A- The intermediate accumulation type of the collectorR- The final result type of the collector- Parameters:
collector- aCollectorto adapt- Returns:
- a
DoubleCollectorwhich behaves in the same way as input collector.
-
of
static <A,R> DoubleCollector<A,R> of(Supplier<A> supplier, ObjDoubleConsumer<A> doubleAccumulator, BiConsumer<A, A> merger, Function<A, R> finisher) Returns a newDoubleCollectordescribed by the givensupplier,accumulator,merger, andfinisherfunctions.- Type Parameters:
A- The intermediate accumulation type of the new collectorR- The final result type of the new collector- Parameters:
supplier- The supplier function for the new collectordoubleAccumulator- The doubleAccumulator function for the new collectormerger- The merger function for the new collectorfinisher- The finisher function for the new collector- Returns:
- the new
DoubleCollector
-
joining
static DoubleCollector<?,String> joining(CharSequence delimiter, CharSequence prefix, CharSequence suffix) Returns aDoubleCollectorthat converts the input numbers to strings and concatenates them, separated by the specified delimiter, with the specified prefix and suffix, in encounter order.- Parameters:
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 result- Returns:
- A
DoubleCollectorwhich concatenates the input numbers, separated by the specified delimiter, in encounter order
-
joining
Returns aDoubleCollectorthat converts the input numbers to strings and concatenates them, separated by the specified delimiter, in encounter order.- Parameters:
delimiter- the delimiter to be used between each element- Returns:
- A
DoubleCollectorwhich concatenates the input numbers, separated by the specified delimiter, in encounter order
-
counting
Returns aDoubleCollectorthat counts the number of input elements and returns the result asLong. If no elements are present, the result is 0.- Returns:
- a
DoubleCollectorthat counts the input elements
-
countingInt
Returns anDoubleCollectorthat counts the number of input elements and returns the result asInteger. If no elements are present, the result is 0.- Returns:
- an
DoubleCollectorthat counts the input elements
-
summing
Returns aDoubleCollectorthat produces the sum of the input elements. If no elements are present, the result is 0.0.- Returns:
- a
DoubleCollectorthat produces the sum of the input elements
-
averaging
Returns aDoubleCollectorthat produces the arithmetic mean of the input elements or an empty optional if no elements are collected.- Returns:
- a
DoubleCollectorthat produces the arithmetic mean of the input elements - Since:
- 0.3.7
-
min
Returns aDoubleCollectorthat produces the minimal element, described as anOptionalDouble. If no elements are present, the result is an emptyOptionalDouble.- Returns:
- a
DoubleCollectorthat produces the minimal element.
-
max
Returns aDoubleCollectorthat produces the maximal element, described as anOptionalDouble. If no elements are present, the result is an emptyOptionalDouble.- Returns:
- a
DoubleCollectorthat produces the maximal element.
-
mapping
static <A,R> DoubleCollector<?,R> mapping(DoubleUnaryOperator mapper, DoubleCollector<A, R> downstream) Adapts aDoubleCollectorto another one by applying a mapping function to each input element before accumulation.- Type Parameters:
A- intermediate accumulation type of the downstream collectorR- result type of collector- Parameters:
mapper- a function to be applied to the input elementsdownstream- a collector which will accept mapped values- Returns:
- a collector which applies the mapping function to the input elements and provides the mapped results to the downstream collector
-
mappingToObj
static <U,A, DoubleCollector<?,R> R> mappingToObj(DoubleFunction<U> mapper, Collector<U, A, R> downstream) Adapts aCollectoraccepting elements of typeUto aDoubleCollectorby applying a mapping function to each input element before accumulation.- Type Parameters:
U- type of elements accepted by downstream collectorA- intermediate accumulation type of the downstream collectorR- result type of collector- Parameters:
mapper- a function to be applied to the input elementsdownstream- a collector which will accept mapped values- Returns:
- a collector which applies the mapping function to the input elements and provides the mapped results to the downstream collector
-
reducing
Returns aDoubleCollectorwhich performs a reduction of its input numbers under a specifiedDoubleBinaryOperator. The result is described as anOptionalDouble.- Parameters:
op- aDoubleBinaryOperatorused to reduce the input numbers- Returns:
- a
DoubleCollectorwhich implements the reduction operation.
-
reducing
Returns aDoubleCollectorwhich performs a reduction of its input numbers under a specifiedIntBinaryOperatorusing the provided identity.- Parameters:
identity- the identity value for the reduction (also, the value that is returned when there are no input elements)op- aDoubleBinaryOperatorused to reduce the input numbers- Returns:
- a
DoubleCollectorwhich implements the reduction operation
-
summarizing
Returns aDoubleCollectorwhich returns summary statistics for the input elements.- Returns:
- a
DoubleCollectorimplementing the summary-statistics reduction
-
partitioningBy
Returns aDoubleCollectorwhich partitions the input elements according to aDoublePredicate, and organizes them into aMap<Boolean, double[]>.There are no guarantees on the type, mutability, serializability, or thread-safety of the
Mapreturned.- Parameters:
predicate- a predicate used for classifying input elements- Returns:
- a
DoubleCollectorimplementing the partitioning operation
-
partitioningBy
static <A,D> DoubleCollector<?, Map<Boolean,D>> partitioningBy(DoublePredicate predicate, DoubleCollector<A, D> downstream) Returns aDoubleCollectorwhich partitions the input numbers according to aDoublePredicate, reduces the values in each partition according to anotherIntCollector, and organizes them into aMap<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
Mapreturned.- Type Parameters:
A- the intermediate accumulation type of the downstream collectorD- the result type of the downstream reduction- Parameters:
predicate- a predicate used for classifying input elementsdownstream- aDoubleCollectorimplementing the downstream reduction- Returns:
- a
DoubleCollectorimplementing the cascaded partitioning operation
-
groupingBy
Returns aDoubleCollectorimplementing a "group by" operation on input numbers, grouping them according to a classification function, and returning the results in aMap.The classification function maps elements to some key type
K. The collector produces aMap<K, double[]>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
Mapobjects returned.- Type Parameters:
K- the type of the keys- Parameters:
classifier- the classifier function mapping input elements to keys- Returns:
- a
DoubleCollectorimplementing the group-by operation
-
groupingBy
static <K,D, DoubleCollector<?,A> Map<K, groupingByD>> (DoubleFunction<? extends K> classifier, DoubleCollector<A, D> downstream) Returns aDoubleCollectorimplementing 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 downstreamIntCollector.The classification function maps elements to some key type
K. The downstream collector produces a result of typeD. The resulting collector produces aMap<K, D>.There are no guarantees on the type, mutability, serializability, or thread-safety of the
Mapreturned.- Type Parameters:
K- the type of the keysD- the result type of the downstream reductionA- the intermediate accumulation type of the downstream collector- Parameters:
classifier- a classifier function mapping input elements to keysdownstream- aDoubleCollectorimplementing the downstream reduction- Returns:
- a
DoubleCollectorimplementing the cascaded group-by operation
-
groupingBy
static <K, D, A, M extends Map<K,D>> DoubleCollector<?,M> groupingBy(DoubleFunction<? extends K> classifier, Supplier<M> mapFactory, DoubleCollector<A, D> downstream) Returns aDoubleCollectorimplementing 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 downstreamIntCollector. TheMapproduced 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 typeD. The resulting collector produces aMap<K, D>.- Type Parameters:
K- the type of the keysD- the result type of the downstream reductionA- the intermediate accumulation type of the downstream collectorM- the type of the resultingMap- Parameters:
classifier- a classifier function mapping input elements to keysmapFactory- a function which, when called, produces a new emptyMapof the desired typedownstream- aDoubleCollectorimplementing the downstream reduction- Returns:
- a
DoubleCollectorimplementing the cascaded group-by operation
-
toArray
Returns aDoubleCollectorthat produces the array of the input elements. If no elements are present, the result is an empty array.- Returns:
- a
DoubleCollectorthat produces the array of the input elements
-
toFloatArray
Returns aDoubleCollectorthat produces thefloat[]array of the input elements converting them via(float)casting. If no elements are present, the result is an empty array.- Returns:
- a
DoubleCollectorthat produces thefloat[]array of the input elements
-
toBooleanArray
Returns aDoubleCollectorwhich produces a boolean array containing the results of applying the given predicate to the input elements, in encounter order.- Parameters:
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.- Returns:
- a
DoubleCollectorwhich collects the results of the predicate function to the boolean array, in encounter order. - Since:
- 0.3.8
-