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 -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate DoubleStreamThe source of elements, ornullif thisDoubleStreamWrapperis no longer the active stream.Fields inherited from class org.apache.sis.internal.stream.BaseStreamWrapper
toClose -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedDoubleStreamWrapper(DoubleStream source) Creates a new wrapper for the given stream. -
Method Summary
Modifier and TypeMethodDescriptionbooleanallMatch(DoublePredicate predicate) Returns whether all elements of this stream match the provided predicate.booleananyMatch(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 asDoubleelements.<R> Rcollect(Supplier<R> supplier, ObjDoubleConsumer<R> accumulator, BiConsumer<R, R> combiner) Performs a mutable reduction on the elements of this stream.longcount()Returns the number of elements in this stream.(package private) final DoubleStreamdelegate()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.voidforEach(DoubleConsumer action) Performs an action for each element of this stream.voidforEachOrdered(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.booleannoneMatch(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.doublereduce(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 DoubleStreamsource()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.doublesum()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 DoubleStreamupdate(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, isParallelMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.util.stream.BaseStream
close, isParallel
-
Field Details
-
source
The source of elements, ornullif thisDoubleStreamWrapperis no longer the active stream. This is initialized at creation time and set tonullafter it has been determined that all subsequent operations shall be done on a new stream instead ofthisstream.
-
-
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:
sourcein 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:
parallelin interfaceBaseStream<Double,DoubleStream> - Specified by:
parallelin interfaceDoubleStream
-
sequential
Returns an equivalent stream that is sequential.- Specified by:
sequentialin interfaceBaseStream<Double,DoubleStream> - Specified by:
sequentialin interfaceDoubleStream
-
unordered
Returns an equivalent stream that is unordered.- Specified by:
unorderedin interfaceBaseStream<Double,DoubleStream>
-
filter
Returns a stream with elements of this stream that match the given predicate.- Specified by:
filterin interfaceDoubleStream
-
map
Returns a stream with results of applying the given function to the elements of this stream.- Specified by:
mapin interfaceDoubleStream
-
mapToObj
Returns a stream with results of applying the given function to the elements of this stream.- Specified by:
mapToObjin interfaceDoubleStream
-
mapToInt
Returns a stream with results of applying the given function to the elements of this stream.- Specified by:
mapToIntin interfaceDoubleStream
-
mapToLong
Returns a stream with results of applying the given function to the elements of this stream.- Specified by:
mapToLongin interfaceDoubleStream
-
flatMap
Returns a stream with results of applying the given function to the elements of this stream.- Specified by:
flatMapin interfaceDoubleStream
-
distinct
Returns a stream with distinct elements of this stream.- Specified by:
distinctin interfaceDoubleStream
-
sorted
Returns a stream with elements of this stream sorted in ascending order.- Specified by:
sortedin interfaceDoubleStream
-
peek
Returns a stream performing the specified action on each element when consumed.- Specified by:
peekin interfaceDoubleStream
-
limit
Returns a stream with truncated at the given number of elements.- Specified by:
limitin interfaceDoubleStream
-
skip
Returns a stream discarding the specified number of elements.- Specified by:
skipin interfaceDoubleStream
-
forEach
Performs an action for each element of this stream.- Specified by:
forEachin interfaceDoubleStream
-
forEachOrdered
Performs an action for each element of this stream in encounter order.- Specified by:
forEachOrderedin interfaceDoubleStream
-
reduce
Performs a reduction on the elements of this stream.- Specified by:
reducein interfaceDoubleStream
-
reduce
Performs a reduction on the elements of this stream.- Specified by:
reducein 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:
collectin interfaceDoubleStream
-
sum
public double sum()Returns the sum of elements of this stream.- Specified by:
sumin interfaceDoubleStream
-
min
Returns the minimum element of this stream.- Specified by:
minin interfaceDoubleStream
-
max
Returns the maximum element of this stream.- Specified by:
maxin interfaceDoubleStream
-
count
public long count()Returns the number of elements in this stream.- Specified by:
countin interfaceDoubleStream
-
average
Returns the average of elements of this stream.- Specified by:
averagein interfaceDoubleStream
-
summaryStatistics
Returns statistics about elements of this stream.- Specified by:
summaryStatisticsin interfaceDoubleStream
-
anyMatch
Returns whether at least one element of this stream matches the provided predicate.- Specified by:
anyMatchin interfaceDoubleStream
-
allMatch
Returns whether all elements of this stream match the provided predicate.- Specified by:
allMatchin interfaceDoubleStream
-
noneMatch
Returns whether none element of this stream match the provided predicate.- Specified by:
noneMatchin interfaceDoubleStream
-
findFirst
Returns the first element of this stream.- Specified by:
findFirstin interfaceDoubleStream
-
findAny
Returns any element of this stream.- Specified by:
findAnyin interfaceDoubleStream
-
boxed
Returns the stream elements asDoubleelements.- Specified by:
boxedin interfaceDoubleStream
-
iterator
Returns an iterator for the elements of this stream.- Specified by:
iteratorin interfaceBaseStream<Double,DoubleStream> - Specified by:
iteratorin interfaceDoubleStream
-
spliterator
Returns a spliterator for the elements of this stream.- Specified by:
spliteratorin interfaceBaseStream<Double,DoubleStream> - Specified by:
spliteratorin interfaceDoubleStream
-
toArray
public double[] toArray()Returns all elements in an array.- Specified by:
toArrayin interfaceDoubleStream
-
onClose
Returns an equivalent stream with an additional close handler.- Specified by:
onClosein interfaceBaseStream<Double,DoubleStream>
-