Package org.apache.sis.internal.stream
Class DoubleStreamWrapper
java.lang.Object
org.apache.sis.internal.stream.BaseStreamWrapper<Double,DoubleStream>
org.apache.sis.internal.stream.DoubleStreamWrapper
- All Implemented Interfaces:
AutoCloseable
,BaseStream<Double,
,DoubleStream> DoubleStream
- Direct Known Subclasses:
PaginedDoubleStream
public abstract class DoubleStreamWrapper
extends BaseStreamWrapper<Double,DoubleStream>
implements DoubleStream
A stream which delegates all operations to another stream of floating point values.
This is equivalent to
StreamWrapper
but specialized for double
primitive type.- Since:
- 1.1
- Version:
- 1.1
-
Nested Class Summary
Nested classes/interfaces inherited from interface java.util.stream.DoubleStream
DoubleStream.Builder, DoubleStream.DoubleMapMultiConsumer
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate DoubleStream
The source of elements, ornull
if thisDoubleStreamWrapper
is no longer the active stream.Fields inherited from class org.apache.sis.internal.stream.BaseStreamWrapper
toClose
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
DoubleStreamWrapper
(DoubleStream source) Creates a new wrapper for the given stream. -
Method Summary
Modifier and TypeMethodDescriptionboolean
allMatch
(DoublePredicate predicate) Returns whether all elements of this stream match the provided predicate.boolean
anyMatch
(DoublePredicate predicate) Returns whether at least one element of this stream matches the provided predicate.average()
Returns the average of elements of this stream.boxed()
Returns the stream elements asDouble
elements.<R> R
collect
(Supplier<R> supplier, ObjDoubleConsumer<R> accumulator, BiConsumer<R, R> combiner) Performs a mutable reduction on the elements of this stream.long
count()
Returns the number of elements in this stream.(package private) final DoubleStream
delegate()
Same assource()
but marks this stream is inactive.distinct()
Returns a stream with distinct elements of this stream.filter
(DoublePredicate predicate) Returns a stream with elements of this stream that match the given predicate.findAny()
Returns any element of this stream.Returns the first element of this stream.flatMap
(DoubleFunction<? extends DoubleStream> mapper) Returns a stream with results of applying the given function to the elements of this stream.void
forEach
(DoubleConsumer action) Performs an action for each element of this stream.void
forEachOrdered
(DoubleConsumer action) Performs an action for each element of this stream in encounter order.iterator()
Returns an iterator for the elements of this stream.limit
(long maxSize) Returns a stream with truncated at the given number of elements.map
(DoubleUnaryOperator mapper) Returns a stream with results of applying the given function to the elements of this stream.mapToInt
(DoubleToIntFunction mapper) Returns a stream with results of applying the given function to the elements of this stream.mapToLong
(DoubleToLongFunction mapper) Returns a stream with results of applying the given function to the elements of this stream.<U> Stream
<U> mapToObj
(DoubleFunction<? extends U> mapper) Returns a stream with results of applying the given function to the elements of this stream.max()
Returns the maximum element of this stream.min()
Returns the minimum element of this stream.boolean
noneMatch
(DoublePredicate predicate) Returns whether none element of this stream match the provided predicate.Returns an equivalent stream with an additional close handler.parallel()
Returns an equivalent stream that is parallel.peek
(DoubleConsumer action) Returns a stream performing the specified action on each element when consumed.double
reduce
(double identity, DoubleBinaryOperator op) Performs a reduction on the elements of this stream.Performs a reduction on the elements of this stream.Returns an equivalent stream that is sequential.skip
(long n) Returns a stream discarding the specified number of elements.sorted()
Returns a stream with elements of this stream sorted in ascending order.(package private) final DoubleStream
source()
Verifies that this stream is still the active one, then returns the source of this stream.Returns a spliterator for the elements of this stream.double
sum()
Returns the sum of elements of this stream.Returns statistics about elements of this stream.double[]
toArray()
Returns all elements in an array.Returns an equivalent stream that is unordered.private DoubleStream
update
(DoubleStream result) Invoked after an intermediate operation for determining which stream is the active one.Methods inherited from class org.apache.sis.internal.stream.BaseStreamWrapper
close, inactive, isParallel
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface java.util.stream.BaseStream
close, isParallel
Methods inherited from interface java.util.stream.DoubleStream
dropWhile, mapMulti, takeWhile
-
Field Details
-
source
The source of elements, ornull
if thisDoubleStreamWrapper
is no longer the active stream. This is initialized at creation time and set tonull
after it has been determined that all subsequent operations shall be done on a new stream instead ofthis
stream.
-
-
Constructor Details
-
DoubleStreamWrapper
Creates a new wrapper for the given stream.- Parameters:
source
- the stream to wrap.
-
-
Method Details
-
source
Verifies that this stream is still the active one, then returns the source of this stream.- Specified by:
source
in classBaseStreamWrapper<Double,
DoubleStream> - Returns:
- the stream containing actual data.
- Throws:
IllegalStateException
- if this stream is no longer the active stream on which to apply operations.
-
delegate
Same assource()
but marks this stream is inactive. All subsequent operations must be done on the returned stream. This is used formap(…)
andflatMap(…)
operations.- Returns:
- the stream containing actual data.
- Throws:
IllegalStateException
- if this stream is no longer the active stream on which to apply operations.
-
update
Invoked after an intermediate operation for determining which stream is the active one. If this stream is still active, then this method returnsthis
. Otherwise the given stream is returned. -
parallel
Returns an equivalent stream that is parallel.- Specified by:
parallel
in interfaceBaseStream<Double,
DoubleStream> - Specified by:
parallel
in interfaceDoubleStream
-
sequential
Returns an equivalent stream that is sequential.- Specified by:
sequential
in interfaceBaseStream<Double,
DoubleStream> - Specified by:
sequential
in interfaceDoubleStream
-
unordered
Returns an equivalent stream that is unordered.- Specified by:
unordered
in interfaceBaseStream<Double,
DoubleStream>
-
filter
Returns a stream with elements of this stream that match the given predicate.- Specified by:
filter
in interfaceDoubleStream
-
map
Returns a stream with results of applying the given function to the elements of this stream.- Specified by:
map
in interfaceDoubleStream
-
mapToObj
Returns a stream with results of applying the given function to the elements of this stream.- Specified by:
mapToObj
in interfaceDoubleStream
-
mapToInt
Returns a stream with results of applying the given function to the elements of this stream.- Specified by:
mapToInt
in interfaceDoubleStream
-
mapToLong
Returns a stream with results of applying the given function to the elements of this stream.- Specified by:
mapToLong
in interfaceDoubleStream
-
flatMap
Returns a stream with results of applying the given function to the elements of this stream.- Specified by:
flatMap
in interfaceDoubleStream
-
distinct
Returns a stream with distinct elements of this stream.- Specified by:
distinct
in interfaceDoubleStream
-
sorted
Returns a stream with elements of this stream sorted in ascending order.- Specified by:
sorted
in interfaceDoubleStream
-
peek
Returns a stream performing the specified action on each element when consumed.- Specified by:
peek
in interfaceDoubleStream
-
limit
Returns a stream with truncated at the given number of elements.- Specified by:
limit
in interfaceDoubleStream
-
skip
Returns a stream discarding the specified number of elements.- Specified by:
skip
in interfaceDoubleStream
-
forEach
Performs an action for each element of this stream.- Specified by:
forEach
in interfaceDoubleStream
-
forEachOrdered
Performs an action for each element of this stream in encounter order.- Specified by:
forEachOrdered
in interfaceDoubleStream
-
reduce
Performs a reduction on the elements of this stream.- Specified by:
reduce
in interfaceDoubleStream
-
reduce
Performs a reduction on the elements of this stream.- Specified by:
reduce
in interfaceDoubleStream
-
collect
public <R> R collect(Supplier<R> supplier, ObjDoubleConsumer<R> accumulator, BiConsumer<R, R> combiner) Performs a mutable reduction on the elements of this stream.- Specified by:
collect
in interfaceDoubleStream
-
sum
public double sum()Returns the sum of elements of this stream.- Specified by:
sum
in interfaceDoubleStream
-
min
Returns the minimum element of this stream.- Specified by:
min
in interfaceDoubleStream
-
max
Returns the maximum element of this stream.- Specified by:
max
in interfaceDoubleStream
-
count
public long count()Returns the number of elements in this stream.- Specified by:
count
in interfaceDoubleStream
-
average
Returns the average of elements of this stream.- Specified by:
average
in interfaceDoubleStream
-
summaryStatistics
Returns statistics about elements of this stream.- Specified by:
summaryStatistics
in interfaceDoubleStream
-
anyMatch
Returns whether at least one element of this stream matches the provided predicate.- Specified by:
anyMatch
in interfaceDoubleStream
-
allMatch
Returns whether all elements of this stream match the provided predicate.- Specified by:
allMatch
in interfaceDoubleStream
-
noneMatch
Returns whether none element of this stream match the provided predicate.- Specified by:
noneMatch
in interfaceDoubleStream
-
findFirst
Returns the first element of this stream.- Specified by:
findFirst
in interfaceDoubleStream
-
findAny
Returns any element of this stream.- Specified by:
findAny
in interfaceDoubleStream
-
boxed
Returns the stream elements asDouble
elements.- Specified by:
boxed
in interfaceDoubleStream
-
iterator
Returns an iterator for the elements of this stream.- Specified by:
iterator
in interfaceBaseStream<Double,
DoubleStream> - Specified by:
iterator
in interfaceDoubleStream
-
spliterator
Returns a spliterator for the elements of this stream.- Specified by:
spliterator
in interfaceBaseStream<Double,
DoubleStream> - Specified by:
spliterator
in interfaceDoubleStream
-
toArray
public double[] toArray()Returns all elements in an array.- Specified by:
toArray
in interfaceDoubleStream
-
onClose
Returns an equivalent stream with an additional close handler.- Specified by:
onClose
in interfaceBaseStream<Double,
DoubleStream>
-