public abstract class DoubleStream
extends java.lang.Object
double
primitive specialization of
Stream
.
The following example illustrates an aggregate operation using
Stream
and DoubleStream
, computing the sum of the weights of the
red widgets:
double sum = widgets.stream()
.filter(w -> w.getColor() == RED)
.mapToDouble(w -> w.getWeight())
.sum();
See the class documentation for Stream
and the package documentation
for java.util.stream for additional
specification of streams, stream operations, stream pipelines, and
parallelism.Stream
,
java.util.streamModifier and Type | Class and Description |
---|---|
static class |
DoubleStream.DoubleStreamEx |
BaseStream.Splitor
Modifier and Type | Method and Description |
---|---|
<R> R |
__(Function<? super DoubleStream,R> transfer) |
abstract OptionalDouble |
average()
Returns an
OptionalDouble describing the arithmetic
mean of elements of this stream, or an empty optional if this
stream is empty. |
abstract Stream<java.lang.Double> |
boxed()
Returns a
Stream consisting of the elements of this stream,
boxed to Double . |
S |
carry(C action)
Same as
peek |
void |
close()
Closes this stream, causing all close handlers for this stream pipeline
to be called.
|
abstract DoubleStream |
collapse(DoubleBiPredicate collapsible,
DoubleBiFunction<java.lang.Double> mergeFunction)
Merge series of adjacent elements which satisfy the given predicate using
the merger function and return a new stream.
|
abstract <R> R |
collect(Supplier<R> supplier,
ObjDoubleConsumer<R> accumulator) |
abstract <R> R |
collect(Supplier<R> supplier,
ObjDoubleConsumer<R> accumulator,
BiConsumer<R,R> combiner)
Performs a mutable
reduction operation on the elements of this stream.
|
static DoubleStream |
concat(java.util.Collection<? extends DoubleStream> c) |
static DoubleStream |
concat(double[]... a) |
static DoubleStream |
concat(DoubleIterator... a) |
static DoubleStream |
concat(DoubleStream... a) |
static DoubleStream |
empty() |
OT |
findAny(P predicate)
Returns an
Optional describing some element of the stream, or an
empty Optional if the stream is empty. |
abstract DoubleStream |
flatArray(DoubleFunction<double[]> mapper) |
abstract DoubleStream |
flatMap(DoubleFunction<? extends DoubleStream> mapper)
Returns a stream consisting of the results of replacing each element of
this stream with the contents of a mapped stream produced by applying
the provided mapping function to each element.
|
abstract FloatStream |
flatMapToFloat(DoubleFunction<? extends FloatStream> mapper) |
abstract IntStream |
flatMapToInt(DoubleFunction<? extends IntStream> mapper) |
abstract LongStream |
flatMapToLong(DoubleFunction<? extends LongStream> mapper) |
abstract <T> Stream<T> |
flatMapToObj(DoubleFunction<? extends Stream<T>> mapper) |
static DoubleStream |
from(float... a) |
static DoubleStream |
from(float[] a,
int fromIndex,
int toIndex) |
static DoubleStream |
generate(DoubleSupplier s) |
abstract OptionalDouble |
head()
Head and tail should be used by pair.
|
abstract DoubleStream |
head2()
Head2 and tail2 should be used by pair.
|
abstract Pair<OptionalDouble,DoubleStream> |
headAndTail() |
abstract Pair<DoubleStream,OptionalDouble> |
headAndTail2() |
boolean |
isParallel()
Returns whether this stream, if a terminal operation were to be executed,
would execute in parallel.
|
static DoubleStream |
iterate(double seed,
DoublePredicate hasNext,
DoubleUnaryOperator f) |
static DoubleStream |
iterate(double seed,
DoubleUnaryOperator f) |
static DoubleStream |
iterate(double seed,
Supplier<java.lang.Boolean> hasNext,
DoubleUnaryOperator f) |
static DoubleStream |
iterate(Supplier<java.lang.Boolean> hasNext,
DoubleSupplier next) |
DoubleIterator |
iterator()
Returns an iterator for the elements of this stream.
|
abstract OptionalDouble |
kthLargest(int k) |
abstract DoubleStream |
map(DoubleUnaryOperator mapper)
Returns a stream consisting of the results of applying the given
function to the elements of this stream.
|
abstract FloatStream |
mapToFloat(DoubleToFloatFunction mapper)
Returns a
FloatStream consisting of the results of applying the
given function to the elements of this stream. |
abstract IntStream |
mapToInt(DoubleToIntFunction mapper)
Returns an
IntStream consisting of the results of applying the
given function to the elements of this stream. |
abstract LongStream |
mapToLong(DoubleToLongFunction mapper)
Returns a
LongStream consisting of the results of applying the
given function to the elements of this stream. |
abstract <U> Stream<U> |
mapToObj(DoubleFunction<? extends U> mapper)
Returns an object-valued
Stream consisting of the results of
applying the given function to the elements of this stream. |
abstract OptionalDouble |
max()
Returns an
OptionalDouble describing the maximum element of this
stream, or an empty OptionalDouble if this stream is empty. |
int |
maxThreadNum()
Return the underlying
maxThreadNum if the stream is parallel, otherwise 1 is returned. |
S |
maxThreadNum(int maxThreadNum)
Returns a parallel stream with the specified
maxThreadNum . |
static DoubleStream |
merge(java.util.Collection<? extends DoubleStream> c,
DoubleBiFunction<com.landawn.abacus.util.Nth> nextSelector) |
static DoubleStream |
merge(double[] a,
double[] b,
double[] c,
DoubleBiFunction<com.landawn.abacus.util.Nth> nextSelector) |
static DoubleStream |
merge(double[] a,
double[] b,
DoubleBiFunction<com.landawn.abacus.util.Nth> nextSelector) |
static DoubleStream |
merge(DoubleIterator a,
DoubleIterator b,
DoubleBiFunction<com.landawn.abacus.util.Nth> nextSelector) |
static DoubleStream |
merge(DoubleIterator a,
DoubleIterator b,
DoubleIterator c,
DoubleBiFunction<com.landawn.abacus.util.Nth> nextSelector) |
abstract DoubleStream |
merge(DoubleStream b,
DoubleBiFunction<com.landawn.abacus.util.Nth> nextSelector) |
static DoubleStream |
merge(DoubleStream a,
DoubleStream b,
DoubleBiFunction<com.landawn.abacus.util.Nth> nextSelector) |
static DoubleStream |
merge(DoubleStream a,
DoubleStream b,
DoubleStream c,
DoubleBiFunction<com.landawn.abacus.util.Nth> nextSelector) |
abstract OptionalDouble |
min()
Returns an
OptionalDouble describing the minimum element of this
stream, or an empty OptionalDouble if this stream is empty. |
static DoubleStream |
of(double... a) |
static DoubleStream |
of(double[][] a) |
static DoubleStream |
of(double[][][] a) |
static DoubleStream |
of(double[] a,
int startIndex,
int endIndex) |
static DoubleStream |
of(DoubleIterator iterator) |
static DoubleStream |
of(java.util.stream.DoubleStream stream) |
static DoubleStream |
of(Supplier<DoubleList> supplier)
Lazy evaluation.
|
S |
parallel()
Returns an equivalent stream that is parallel.
|
S |
parallel(BaseStream.Splitor splitor)
Returns an equivalent stream that is parallel.
|
S |
parallel(int maxThreadNum)
Returns an equivalent stream that is parallel.
|
static DoubleStream |
parallelMerge(java.util.Collection<? extends DoubleStream> c,
DoubleBiFunction<com.landawn.abacus.util.Nth> nextSelector) |
static DoubleStream |
parallelMerge(java.util.Collection<? extends DoubleStream> c,
DoubleBiFunction<com.landawn.abacus.util.Nth> nextSelector,
int maxThreadNum) |
void |
println() |
static DoubleStream |
random() |
abstract OptionalDouble |
reduce(DoubleBinaryOperator op)
Performs a reduction on the
elements of this stream, using an
associative accumulation
function, and returns an
OptionalDouble describing the reduced
value, if any. |
abstract double |
reduce(double identity,
DoubleBinaryOperator op)
Performs a reduction on the
elements of this stream, using the provided identity value and an
associative
accumulation function, and returns the reduced value.
|
static DoubleStream |
repeat(double element,
long n) |
abstract DoubleStream |
scan(DoubleBiFunction<java.lang.Double> accumulator)
Returns a
Stream produced by iterative application of a accumulation function
to an initial element seed and next element of the current stream. |
abstract DoubleStream |
scan(double seed,
DoubleBiFunction<java.lang.Double> accumulator)
Returns a
Stream produced by iterative application of a accumulation function
to an initial element seed and next element of the current stream. |
S |
sequential()
Returns an equivalent stream that is sequential.
|
Stream<S> |
sliding(int windowSize) |
Stream<PL> |
slidingToList(int windowSize) |
BaseStream.Splitor |
splitor()
Return the underlying
splitor if the stream is parallel, otherwise the default value splitor.ITERATOR is returned. |
S |
splitor(BaseStream.Splitor splitor)
Returns a parallel stream with the specified
splitor . |
abstract double |
sum()
Returns the sum of elements in this stream.
|
abstract DoubleSummaryStatistics |
summarize() |
abstract Pair<DoubleSummaryStatistics,Optional<java.util.Map<com.landawn.abacus.util.Percentage,java.lang.Double>>> |
summarize2() |
abstract DoubleStream |
tail()
Head and tail should be used by pair.
|
abstract OptionalDouble |
tail2()
Head2 and tail2 should be used by pair.
|
abstract DoubleList |
toDoubleList() |
abstract <K,A,D> java.util.Map<K,D> |
toMap(DoubleFunction<? extends K> classifier,
Collector<java.lang.Double,A,D> downstream) |
abstract <K,A,D,M extends java.util.Map<K,D>> |
toMap(DoubleFunction<? extends K> classifier,
Collector<java.lang.Double,A,D> downstream,
Supplier<M> mapFactory) |
abstract <K,U> java.util.Map<K,U> |
toMap(DoubleFunction<? extends K> keyExtractor,
DoubleFunction<? extends U> valueMapper) |
abstract <K,U> java.util.Map<K,U> |
toMap(DoubleFunction<? extends K> keyExtractor,
DoubleFunction<? extends U> valueMapper,
BinaryOperator<U> mergeFunction) |
abstract <K,U,M extends java.util.Map<K,U>> |
toMap(DoubleFunction<? extends K> keyExtractor,
DoubleFunction<? extends U> valueMapper,
BinaryOperator<U> mergeFunction,
Supplier<M> mapFactory) |
abstract <K,U,M extends java.util.Map<K,U>> |
toMap(DoubleFunction<? extends K> keyExtractor,
DoubleFunction<? extends U> valueMapper,
Supplier<M> mapFactory) |
abstract DoubleMatrix |
toMatrix() |
abstract DoubleStream |
top(int n)
This method only run sequentially, even in parallel stream. |
abstract DoubleStream |
top(int n,
java.util.Comparator<? super java.lang.Double> comparator)
This method only run sequentially, even in parallel stream. |
Try<S> |
tried() |
static DoubleStream |
zip(java.util.Collection<? extends DoubleStream> c,
double[] valuesForNone,
DoubleNFunction<java.lang.Double> zipFunction)
Zip together the iterators until all of them runs out of values.
|
static DoubleStream |
zip(java.util.Collection<? extends DoubleStream> c,
DoubleNFunction<java.lang.Double> zipFunction)
Zip together the iterators until one of them runs out of values.
|
static DoubleStream |
zip(double[] a,
double[] b,
double[] c,
double valueForNoneA,
double valueForNoneB,
double valueForNoneC,
DoubleTriFunction<java.lang.Double> zipFunction)
Zip together the "a", "b" and "c" iterators until all of them runs out of values.
|
static DoubleStream |
zip(double[] a,
double[] b,
double[] c,
DoubleTriFunction<java.lang.Double> zipFunction)
Zip together the "a", "b" and "c" arrays until one of them runs out of values.
|
static DoubleStream |
zip(double[] a,
double[] b,
DoubleBiFunction<java.lang.Double> zipFunction)
Zip together the "a" and "b" arrays until one of them runs out of values.
|
static DoubleStream |
zip(double[] a,
double[] b,
double valueForNoneA,
double valueForNoneB,
DoubleBiFunction<java.lang.Double> zipFunction)
Zip together the "a" and "b" iterators until all of them runs out of values.
|
static DoubleStream |
zip(DoubleIterator a,
DoubleIterator b,
DoubleBiFunction<java.lang.Double> zipFunction)
Zip together the "a" and "b" iterators until one of them runs out of values.
|
static DoubleStream |
zip(DoubleIterator a,
DoubleIterator b,
double valueForNoneA,
double valueForNoneB,
DoubleBiFunction<java.lang.Double> zipFunction)
Zip together the "a" and "b" iterators until all of them runs out of values.
|
static DoubleStream |
zip(DoubleIterator a,
DoubleIterator b,
DoubleIterator c,
double valueForNoneA,
double valueForNoneB,
double valueForNoneC,
DoubleTriFunction<java.lang.Double> zipFunction)
Zip together the "a", "b" and "c" iterators until all of them runs out of values.
|
static DoubleStream |
zip(DoubleIterator a,
DoubleIterator b,
DoubleIterator c,
DoubleTriFunction<java.lang.Double> zipFunction)
Zip together the "a", "b" and "c" iterators until one of them runs out of values.
|
static DoubleStream |
zip(DoubleStream a,
DoubleStream b,
DoubleBiFunction<java.lang.Double> zipFunction)
Zip together the "a" and "b" streams until one of them runs out of values.
|
static DoubleStream |
zip(DoubleStream a,
DoubleStream b,
double valueForNoneA,
double valueForNoneB,
DoubleBiFunction<java.lang.Double> zipFunction)
Zip together the "a" and "b" iterators until all of them runs out of values.
|
static DoubleStream |
zip(DoubleStream a,
DoubleStream b,
DoubleStream c,
double valueForNoneA,
double valueForNoneB,
double valueForNoneC,
DoubleTriFunction<java.lang.Double> zipFunction)
Zip together the "a", "b" and "c" iterators until all of them runs out of values.
|
static DoubleStream |
zip(DoubleStream a,
DoubleStream b,
DoubleStream c,
DoubleTriFunction<java.lang.Double> zipFunction)
Zip together the "a", "b" and "c" streams until one of them runs out of values.
|
abstract DoubleStream |
zipWith(DoubleStream b,
DoubleBiFunction<java.lang.Double> zipFunction) |
abstract DoubleStream |
zipWith(DoubleStream b,
double valueForNoneA,
double valueForNoneB,
DoubleBiFunction<java.lang.Double> zipFunction) |
abstract DoubleStream |
zipWith(DoubleStream b,
DoubleStream c,
double valueForNoneA,
double valueForNoneB,
double valueForNoneC,
DoubleTriFunction<java.lang.Double> zipFunction) |
abstract DoubleStream |
zipWith(DoubleStream b,
DoubleStream c,
DoubleTriFunction<java.lang.Double> zipFunction) |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
allMatch, anyMatch, append, cached, count, difference, distinct, dropWhile, filter, findFirst, findFirstOrLast, findLast, first, forEach, indexed, intersection, join, join, last, limit, noneMatch, onClose, parallel, peek, percentiles, prepend, remove, removeIf, removeIf, removeWhile, reversed, reverseSorted, rotated, shuffled, shuffled, skip, sliding, slidingToList, sorted, split, split, split, splitAt, splitBy, splitToList, splitToList, splitToList, step, symmetricDifference, takeWhile, toArray, toList, toList, toLongMultiset, toLongMultiset, toMultiset, toMultiset, toSet, toSet
public abstract DoubleStream map(DoubleUnaryOperator mapper)
This is an intermediate operation.
mapper
- a non-interfering,
stateless
function to apply to each elementpublic abstract IntStream mapToInt(DoubleToIntFunction mapper)
IntStream
consisting of the results of applying the
given function to the elements of this stream.
This is an intermediate operation.
mapper
- a non-interfering,
stateless
function to apply to each elementpublic abstract LongStream mapToLong(DoubleToLongFunction mapper)
LongStream
consisting of the results of applying the
given function to the elements of this stream.
This is an intermediate operation.
mapper
- a non-interfering,
stateless
function to apply to each elementpublic abstract FloatStream mapToFloat(DoubleToFloatFunction mapper)
FloatStream
consisting of the results of applying the
given function to the elements of this stream.
This is an intermediate operation.
mapper
- a non-interfering,
stateless
function to apply to each elementpublic abstract <U> Stream<U> mapToObj(DoubleFunction<? extends U> mapper)
Stream
consisting of the results of
applying the given function to the elements of this stream.
This is an intermediate operation.
U
- the element type of the new streammapper
- a non-interfering,
stateless
function to apply to each elementpublic abstract DoubleStream flatMap(DoubleFunction<? extends DoubleStream> mapper)
This is an intermediate operation.
mapper
- a non-interfering,
stateless
function to apply to each element which produces a
DoubleStream
of new valuesStream.flatMap(Function)
public abstract DoubleStream flatArray(DoubleFunction<double[]> mapper)
public abstract IntStream flatMapToInt(DoubleFunction<? extends IntStream> mapper)
public abstract LongStream flatMapToLong(DoubleFunction<? extends LongStream> mapper)
public abstract FloatStream flatMapToFloat(DoubleFunction<? extends FloatStream> mapper)
public abstract <T> Stream<T> flatMapToObj(DoubleFunction<? extends Stream<T>> mapper)
public abstract DoubleStream collapse(DoubleBiPredicate collapsible, DoubleBiFunction<java.lang.Double> mergeFunction)
collapsible
- mergeFunction
- public abstract DoubleStream scan(DoubleBiFunction<java.lang.Double> accumulator)
Stream
produced by iterative application of a accumulation function
to an initial element seed
and next element of the current stream.
Produces a Stream
consisting of seed
, acc(seed, value1)
,
acc(acc(seed, value1), value2)
, etc.
This is an intermediate operation.
Example:
accumulator: (a, b) -> a + b stream: [1, 2, 3, 4, 5] result: [1, 3, 6, 10, 15]
accumulator
- the accumulation functionpublic abstract DoubleStream scan(double seed, DoubleBiFunction<java.lang.Double> accumulator)
Stream
produced by iterative application of a accumulation function
to an initial element seed
and next element of the current stream.
Produces a Stream
consisting of seed
, acc(seed, value1)
,
acc(acc(seed, value1), value2)
, etc.
This is an intermediate operation.
Example:
seed:10 accumulator: (a, b) -> a + b stream: [1, 2, 3, 4, 5] result: [11, 13, 16, 20, 25]
seed
- the initial value. it's only used once by accumulator
to calculate the fist element in the returned stream.
It will be ignored if this stream is empty and won't be the first element of the returned stream.accumulator
- the accumulation functionpublic abstract DoubleStream top(int n)
n
- public abstract DoubleStream top(int n, java.util.Comparator<? super java.lang.Double> comparator)
n
- comparator
- public abstract DoubleList toDoubleList()
public abstract <K,U> java.util.Map<K,U> toMap(DoubleFunction<? extends K> keyExtractor, DoubleFunction<? extends U> valueMapper)
keyExtractor
- valueMapper
- Collectors.toMap(Function, Function)
public abstract <K,U,M extends java.util.Map<K,U>> M toMap(DoubleFunction<? extends K> keyExtractor, DoubleFunction<? extends U> valueMapper, Supplier<M> mapFactory)
keyExtractor
- valueMapper
- mapFactory
- Collectors.toMap(Function, Function, Supplier)
public abstract <K,U> java.util.Map<K,U> toMap(DoubleFunction<? extends K> keyExtractor, DoubleFunction<? extends U> valueMapper, BinaryOperator<U> mergeFunction)
keyExtractor
- valueMapper
- mergeFunction
- Collectors.toMap(Function, Function, BinaryOperator)
public abstract <K,U,M extends java.util.Map<K,U>> M toMap(DoubleFunction<? extends K> keyExtractor, DoubleFunction<? extends U> valueMapper, BinaryOperator<U> mergeFunction, Supplier<M> mapFactory)
keyExtractor
- valueMapper
- mergeFunction
- mapFactory
- Collectors.toMap(Function, Function, BinaryOperator, Supplier)
public abstract <K,A,D> java.util.Map<K,D> toMap(DoubleFunction<? extends K> classifier, Collector<java.lang.Double,A,D> downstream)
classifier
- downstream
- Collectors.groupingBy(Function, Collector)
public abstract <K,A,D,M extends java.util.Map<K,D>> M toMap(DoubleFunction<? extends K> classifier, Collector<java.lang.Double,A,D> downstream, Supplier<M> mapFactory)
classifier
- downstream
- mapFactory
- Collectors.groupingBy(Function, Collector, Supplier)
public abstract DoubleMatrix toMatrix()
public abstract double reduce(double identity, DoubleBinaryOperator op)
double result = identity;
for (double element : this stream)
result = accumulator.applyAsDouble(result, element)
return result;
but is not constrained to execute sequentially.
The identity
value must be an identity for the accumulator
function. This means that for all x
,
accumulator.apply(identity, x)
is equal to x
.
The accumulator
function must be an
associative function.
This is a terminal operation.
identity
- the identity value for the accumulating functionop
- an associative,
non-interfering,
stateless
function for combining two valuessum()
,
min()
,
max()
,
average()
public abstract OptionalDouble reduce(DoubleBinaryOperator op)
OptionalDouble
describing the reduced
value, if any. This is equivalent to:
boolean foundAny = false;
double result = null;
for (double element : this stream) {
if (!foundAny) {
foundAny = true;
result = element;
}
else
result = accumulator.applyAsDouble(result, element);
}
return foundAny ? OptionalDouble.of(result) : OptionalDouble.empty();
but is not constrained to execute sequentially.
The accumulator
function must be an
associative function.
This is a terminal operation.
op
- an associative,
non-interfering,
stateless
function for combining two valuesreduce(double, DoubleBinaryOperator)
public abstract <R> R collect(Supplier<R> supplier, ObjDoubleConsumer<R> accumulator, BiConsumer<R,R> combiner)
ArrayList
, and elements are incorporated by updating
the state of the result rather than by replacing the result. This
produces a result equivalent to:
R result = supplier.get();
for (double element : this stream)
accumulator.accept(result, element);
return result;
Like reduce(double, DoubleBinaryOperator)
, collect
operations can be parallelized without requiring additional
synchronization.
This is a terminal operation.
R
- type of the resultsupplier
- a function that creates a new result container. For a
parallel execution, this function may be called
multiple times and must return a fresh value each time.accumulator
- an associative,
non-interfering,
stateless
function for incorporating an additional element into a resultcombiner
- an associative,
non-interfering,
stateless
function for combining two values, which must be
compatible with the accumulator functionStream.collect(Supplier, BiConsumer, BiConsumer)
public abstract <R> R collect(Supplier<R> supplier, ObjDoubleConsumer<R> accumulator)
supplier
- accumulator
- public abstract OptionalDouble head()
public abstract DoubleStream tail()
public abstract DoubleStream head2()
public abstract OptionalDouble tail2()
public abstract Pair<OptionalDouble,DoubleStream> headAndTail()
public abstract Pair<DoubleStream,OptionalDouble> headAndTail2()
public abstract OptionalDouble min()
OptionalDouble
describing the minimum element of this
stream, or an empty OptionalDouble if this stream is empty. The minimum
element will be Double.NaN
if any stream element was NaN. Unlike
the numerical comparison operators, this method considers negative zero
to be strictly smaller than positive zero. This is a special case of a
reduction and is
equivalent to:
return reduce(Double::min);
This is a terminal operation.
OptionalDouble
containing the minimum element of this
stream, or an empty optional if the stream is emptypublic abstract OptionalDouble max()
OptionalDouble
describing the maximum element of this
stream, or an empty OptionalDouble if this stream is empty. The maximum
element will be Double.NaN
if any stream element was NaN. Unlike
the numerical comparison operators, this method considers negative zero
to be strictly smaller than positive zero. This is a
special case of a
reduction and is
equivalent to:
return reduce(Double::max);
This is a terminal operation.
OptionalDouble
containing the maximum element of this
stream, or an empty optional if the stream is emptypublic abstract OptionalDouble kthLargest(int k)
k
- public abstract double sum()
return reduce(0, Double::sum);
However, since floating-point summation is not exact, the above
code is not necessarily equivalent to the summation computation
done by this method.
If any stream element is a NaN or the sum is at any point a NaN
then the sum will be NaN.
The value of a floating-point sum is a function both
of the input values as well as the order of addition
operations. The order of addition operations of this method is
intentionally not defined to allow for implementation
flexibility to improve the speed and accuracy of the computed
result.
In particular, this method may be implemented using compensated
summation or other technique to reduce the error bound in the
numerical sum compared to a simple summation of double
values.
This is a terminal operation.
public abstract OptionalDouble average()
OptionalDouble
describing the arithmetic
mean of elements of this stream, or an empty optional if this
stream is empty.
If any recorded value is a NaN or the sum is at any point a NaN
then the average will be NaN.
The average returned can vary depending upon the order in
which values are recorded.
This method may be implemented using compensated summation or
other technique to reduce the error bound in the numerical sum
used to compute the average.
The average is a special case of a reduction.
This is a terminal operation.
OptionalDouble
containing the average element of this
stream, or an empty optional if the stream is emptypublic abstract DoubleSummaryStatistics summarize()
public abstract Pair<DoubleSummaryStatistics,Optional<java.util.Map<com.landawn.abacus.util.Percentage,java.lang.Double>>> summarize2()
public abstract DoubleStream merge(DoubleStream b, DoubleBiFunction<com.landawn.abacus.util.Nth> nextSelector)
b
- nextSelector
- first parameter is selected if Nth.FIRST
is returned, otherwise the second parameter is selected.public abstract DoubleStream zipWith(DoubleStream b, DoubleBiFunction<java.lang.Double> zipFunction)
public abstract DoubleStream zipWith(DoubleStream b, DoubleStream c, DoubleTriFunction<java.lang.Double> zipFunction)
public abstract DoubleStream zipWith(DoubleStream b, double valueForNoneA, double valueForNoneB, DoubleBiFunction<java.lang.Double> zipFunction)
public abstract DoubleStream zipWith(DoubleStream b, DoubleStream c, double valueForNoneA, double valueForNoneB, double valueForNoneC, DoubleTriFunction<java.lang.Double> zipFunction)
public abstract Stream<java.lang.Double> boxed()
Stream
consisting of the elements of this stream,
boxed to Double
.
This is an intermediate operation.
Stream
consistent of the elements of this stream,
each boxed to a Double
public DoubleIterator iterator()
BaseStream
public <R> R __(Function<? super DoubleStream,R> transfer)
public static DoubleStream empty()
@SafeVarargs public static DoubleStream of(double... a)
public static DoubleStream of(double[] a, int startIndex, int endIndex)
public static DoubleStream of(double[][] a)
public static DoubleStream of(double[][][] a)
public static DoubleStream of(DoubleIterator iterator)
public static DoubleStream of(Supplier<DoubleList> supplier)
supplier
- public static DoubleStream of(java.util.stream.DoubleStream stream)
@SafeVarargs public static DoubleStream from(float... a)
public static DoubleStream from(float[] a, int fromIndex, int toIndex)
public static DoubleStream repeat(double element, long n)
public static DoubleStream random()
public static DoubleStream iterate(Supplier<java.lang.Boolean> hasNext, DoubleSupplier next)
public static DoubleStream iterate(double seed, Supplier<java.lang.Boolean> hasNext, DoubleUnaryOperator f)
public static DoubleStream iterate(double seed, DoublePredicate hasNext, DoubleUnaryOperator f)
seed
- hasNext
- test if has next by hasNext.test(seed) for first time and hasNext.test(f.apply(previous)) for remaining.f
- public static DoubleStream iterate(double seed, DoubleUnaryOperator f)
public static DoubleStream generate(DoubleSupplier s)
@SafeVarargs public static DoubleStream concat(double[]... a)
@SafeVarargs public static DoubleStream concat(DoubleIterator... a)
@SafeVarargs public static DoubleStream concat(DoubleStream... a)
public static DoubleStream concat(java.util.Collection<? extends DoubleStream> c)
public static DoubleStream zip(double[] a, double[] b, DoubleBiFunction<java.lang.Double> zipFunction)
a
- b
- public static DoubleStream zip(double[] a, double[] b, double[] c, DoubleTriFunction<java.lang.Double> zipFunction)
a
- b
- public static DoubleStream zip(DoubleIterator a, DoubleIterator b, DoubleBiFunction<java.lang.Double> zipFunction)
a
- b
- public static DoubleStream zip(DoubleIterator a, DoubleIterator b, DoubleIterator c, DoubleTriFunction<java.lang.Double> zipFunction)
a
- b
- public static DoubleStream zip(DoubleStream a, DoubleStream b, DoubleBiFunction<java.lang.Double> zipFunction)
a
- b
- public static DoubleStream zip(DoubleStream a, DoubleStream b, DoubleStream c, DoubleTriFunction<java.lang.Double> zipFunction)
a
- b
- public static DoubleStream zip(java.util.Collection<? extends DoubleStream> c, DoubleNFunction<java.lang.Double> zipFunction)
c
- zipFunction
- public static DoubleStream zip(double[] a, double[] b, double valueForNoneA, double valueForNoneB, DoubleBiFunction<java.lang.Double> zipFunction)
a
- b
- valueForNoneA
- value to fill if "a" runs out of values first.valueForNoneB
- value to fill if "b" runs out of values first.zipFunction
- public static DoubleStream zip(double[] a, double[] b, double[] c, double valueForNoneA, double valueForNoneB, double valueForNoneC, DoubleTriFunction<java.lang.Double> zipFunction)
a
- b
- c
- valueForNoneA
- value to fill if "a" runs out of values.valueForNoneB
- value to fill if "b" runs out of values.valueForNoneC
- value to fill if "c" runs out of values.zipFunction
- public static DoubleStream zip(DoubleIterator a, DoubleIterator b, double valueForNoneA, double valueForNoneB, DoubleBiFunction<java.lang.Double> zipFunction)
a
- b
- valueForNoneA
- value to fill if "a" runs out of values first.valueForNoneB
- value to fill if "b" runs out of values first.zipFunction
- public static DoubleStream zip(DoubleIterator a, DoubleIterator b, DoubleIterator c, double valueForNoneA, double valueForNoneB, double valueForNoneC, DoubleTriFunction<java.lang.Double> zipFunction)
a
- b
- c
- valueForNoneA
- value to fill if "a" runs out of values.valueForNoneB
- value to fill if "b" runs out of values.valueForNoneC
- value to fill if "c" runs out of values.zipFunction
- public static DoubleStream zip(DoubleStream a, DoubleStream b, double valueForNoneA, double valueForNoneB, DoubleBiFunction<java.lang.Double> zipFunction)
a
- b
- valueForNoneA
- value to fill if "a" runs out of values first.valueForNoneB
- value to fill if "b" runs out of values first.zipFunction
- public static DoubleStream zip(DoubleStream a, DoubleStream b, DoubleStream c, double valueForNoneA, double valueForNoneB, double valueForNoneC, DoubleTriFunction<java.lang.Double> zipFunction)
a
- b
- c
- valueForNoneA
- value to fill if "a" runs out of values.valueForNoneB
- value to fill if "b" runs out of values.valueForNoneC
- value to fill if "c" runs out of values.zipFunction
- public static DoubleStream zip(java.util.Collection<? extends DoubleStream> c, double[] valuesForNone, DoubleNFunction<java.lang.Double> zipFunction)
c
- valuesForNone
- value to fill for any iterator runs out of values.zipFunction
- public static DoubleStream merge(double[] a, double[] b, DoubleBiFunction<com.landawn.abacus.util.Nth> nextSelector)
a
- b
- nextSelector
- first parameter is selected if Nth.FIRST
is returned, otherwise the second parameter is selected.public static DoubleStream merge(double[] a, double[] b, double[] c, DoubleBiFunction<com.landawn.abacus.util.Nth> nextSelector)
a
- b
- c
- nextSelector
- first parameter is selected if Nth.FIRST
is returned, otherwise the second parameter is selected.public static DoubleStream merge(DoubleIterator a, DoubleIterator b, DoubleBiFunction<com.landawn.abacus.util.Nth> nextSelector)
a
- b
- nextSelector
- first parameter is selected if Nth.FIRST
is returned, otherwise the second parameter is selected.public static DoubleStream merge(DoubleIterator a, DoubleIterator b, DoubleIterator c, DoubleBiFunction<com.landawn.abacus.util.Nth> nextSelector)
a
- b
- c
- nextSelector
- first parameter is selected if Nth.FIRST
is returned, otherwise the second parameter is selected.public static DoubleStream merge(DoubleStream a, DoubleStream b, DoubleBiFunction<com.landawn.abacus.util.Nth> nextSelector)
a
- b
- nextSelector
- first parameter is selected if Nth.FIRST
is returned, otherwise the second parameter is selected.public static DoubleStream merge(DoubleStream a, DoubleStream b, DoubleStream c, DoubleBiFunction<com.landawn.abacus.util.Nth> nextSelector)
a
- b
- c
- nextSelector
- first parameter is selected if Nth.FIRST
is returned, otherwise the second parameter is selected.public static DoubleStream merge(java.util.Collection<? extends DoubleStream> c, DoubleBiFunction<com.landawn.abacus.util.Nth> nextSelector)
c
- nextSelector
- first parameter is selected if Nth.FIRST
is returned, otherwise the second parameter is selected.public static DoubleStream parallelMerge(java.util.Collection<? extends DoubleStream> c, DoubleBiFunction<com.landawn.abacus.util.Nth> nextSelector)
c
- nextSelector
- first parameter is selected if Nth.FIRST
is returned, otherwise the second parameter is selected.public static DoubleStream parallelMerge(java.util.Collection<? extends DoubleStream> c, DoubleBiFunction<com.landawn.abacus.util.Nth> nextSelector, int maxThreadNum)
c
- nextSelector
- first parameter is selected if Nth.FIRST
is returned, otherwise the second parameter is selected.maxThreadNum
- public S carry(C action)
BaseStream
peek
carry
in interface BaseStream<T,A,P,C,PL,OT,IT,S extends com.landawn.abacus.util.stream.StreamBase<T,A,P,C,PL,OT,IT,S>>
BaseStream.peek(Object)
public OT findAny(P predicate)
BaseStream
Optional
describing some element of the stream, or an
empty Optional
if the stream is empty.
This is a short-circuiting terminal operation.
The behavior of this operation is explicitly nondeterministic; it is
free to select any element in the stream. This is to allow for maximal
performance in parallel operations; the cost is that multiple invocations
on the same source may not return the same result. (If a stable result
is desired, use #findFirst()
instead.)
findAny
in interface BaseStream<T,A,P,C,PL,OT,IT,S extends com.landawn.abacus.util.stream.StreamBase<T,A,P,C,PL,OT,IT,S>>
Optional
describing some element of this stream, or an
empty Optional
if the stream is empty#findFirst()
public Stream<S> sliding(int windowSize)
sliding
in interface BaseStream<T,A,P,C,PL,OT,IT,S extends com.landawn.abacus.util.stream.StreamBase<T,A,P,C,PL,OT,IT,S>>
BaseStream.sliding(int, int)
public Stream<PL> slidingToList(int windowSize)
slidingToList
in interface BaseStream<T,A,P,C,PL,OT,IT,S extends com.landawn.abacus.util.stream.StreamBase<T,A,P,C,PL,OT,IT,S>>
BaseStream.sliding(int, int)
public void println()
println
in interface BaseStream<T,A,P,C,PL,OT,IT,S extends com.landawn.abacus.util.stream.StreamBase<T,A,P,C,PL,OT,IT,S>>
public boolean isParallel()
BaseStream
isParallel
in interface BaseStream<T,A,P,C,PL,OT,IT,S extends com.landawn.abacus.util.stream.StreamBase<T,A,P,C,PL,OT,IT,S>>
true
if this stream would execute in parallel if executedpublic S sequential()
BaseStream
sequential
in interface BaseStream<T,A,P,C,PL,OT,IT,S extends com.landawn.abacus.util.stream.StreamBase<T,A,P,C,PL,OT,IT,S>>
public S parallel()
BaseStream
parallel
in interface BaseStream<T,A,P,C,PL,OT,IT,S extends com.landawn.abacus.util.stream.StreamBase<T,A,P,C,PL,OT,IT,S>>
BaseStream.parallel(int, Splitor)
public S parallel(int maxThreadNum)
BaseStream
maxThreadNum
as the specified one.parallel
in interface BaseStream<T,A,P,C,PL,OT,IT,S extends com.landawn.abacus.util.stream.StreamBase<T,A,P,C,PL,OT,IT,S>>
BaseStream.parallel(int, Splitor)
public S parallel(BaseStream.Splitor splitor)
BaseStream
splitor
as the specified one.parallel
in interface BaseStream<T,A,P,C,PL,OT,IT,S extends com.landawn.abacus.util.stream.StreamBase<T,A,P,C,PL,OT,IT,S>>
BaseStream.parallel(int, Splitor)
public int maxThreadNum()
BaseStream
maxThreadNum
if the stream is parallel, otherwise 1
is returned.maxThreadNum
in interface BaseStream<T,A,P,C,PL,OT,IT,S extends com.landawn.abacus.util.stream.StreamBase<T,A,P,C,PL,OT,IT,S>>
public S maxThreadNum(int maxThreadNum)
BaseStream
maxThreadNum
. Or return
itself, either because the stream was already parallel with same maxThreadNum
, or because
it's a sequential stream.maxThreadNum
in interface BaseStream<T,A,P,C,PL,OT,IT,S extends com.landawn.abacus.util.stream.StreamBase<T,A,P,C,PL,OT,IT,S>>
public BaseStream.Splitor splitor()
BaseStream
splitor
if the stream is parallel, otherwise the default value splitor.ITERATOR
is returned.splitor
in interface BaseStream<T,A,P,C,PL,OT,IT,S extends com.landawn.abacus.util.stream.StreamBase<T,A,P,C,PL,OT,IT,S>>
public S splitor(BaseStream.Splitor splitor)
BaseStream
splitor
. Or return
itself, either because the stream was already parallel with same splitor
, or because
it's a sequential stream.splitor
in interface BaseStream<T,A,P,C,PL,OT,IT,S extends com.landawn.abacus.util.stream.StreamBase<T,A,P,C,PL,OT,IT,S>>
public Try<S> tried()
tried
in interface BaseStream<T,A,P,C,PL,OT,IT,S extends com.landawn.abacus.util.stream.StreamBase<T,A,P,C,PL,OT,IT,S>>
public void close()
BaseStream
close
in interface BaseStream<T,A,P,C,PL,OT,IT,S extends com.landawn.abacus.util.stream.StreamBase<T,A,P,C,PL,OT,IT,S>>
close
in interface java.lang.AutoCloseable
AutoCloseable.close()