public final class DoubleStreams extends Object
takeWhile()
,
dropWhile()
) in the DoubleStream
interface.Modifier and Type | Method and Description |
---|---|
static DoubleStream.Builder |
builder()
Returns a builder for a
DoubleStream . |
static DoubleStream |
concat(DoubleStream a,
DoubleStream b)
Creates a lazily concatenated stream whose elements are all the
elements of the first stream followed by all the elements of the
second stream.
|
static DoubleStream |
dropWhile(DoubleStream stream,
DoublePredicate predicate)
Returns a stream consisting of the remaining elements of the passed
stream after discarding elements that match the given predicate up to,
but not discarding, the first element encountered that does not match the
predicate.
|
static DoubleStream |
empty()
Returns an empty sequential
DoubleStream . |
static DoubleStream |
generate(DoubleSupplier s)
Returns an infinite sequential unordered stream where each element is
generated by the provided
DoubleSupplier . |
static DoubleStream |
iterate(double seed,
DoubleUnaryOperator f)
Returns an infinite sequential ordered
DoubleStream produced by iterative
application of a function f to an initial element seed ,
producing a Stream consisting of seed , f(seed) ,
f(f(seed)) , etc. |
static DoubleStream |
of(double... values)
Returns a sequential ordered stream whose elements are the specified values.
|
static DoubleStream |
of(double t)
Returns a sequential
DoubleStream containing a single element. |
static DoubleStream |
takeWhile(DoubleStream stream,
DoublePredicate predicate)
Returns a stream consisting of elements of the passed stream that match
the given predicate up to, but discarding, the first element encountered
that does not match the predicate.
|
public static DoubleStream takeWhile(DoubleStream stream, DoublePredicate predicate)
stream
- the stream to wrap for the takeWhile()
operationpredicate
- a non-interfering,
predicate to apply to each element to determine if it
should be included, or it and all subsequently
encountered elements be discarded.public static DoubleStream dropWhile(DoubleStream stream, DoublePredicate predicate)
This is a stateful intermediate operation.
stream
- the stream to wrap for the dropWhile()
operationpredicate
- a non-interfering,
predicate to apply to each element to determine if it
should be discarded, or it and all subsequently
encountered elements be included.public static DoubleStream.Builder builder()
DoubleStream
.public static DoubleStream empty()
DoubleStream
.public static DoubleStream of(double t)
DoubleStream
containing a single element.t
- the single elementpublic static DoubleStream of(double... values)
values
- the elements of the new streampublic static DoubleStream iterate(double seed, DoubleUnaryOperator f)
DoubleStream
produced by iterative
application of a function f
to an initial element seed
,
producing a Stream
consisting of seed
, f(seed)
,
f(f(seed))
, etc.
The first element (position 0
) in the DoubleStream
will be the provided seed
. For n > 0
, the element at
position n
, will be the result of applying the function f
to the element at position n - 1
.
seed
- the initial elementf
- a function to be applied to the previous element to produce
a new elementDoubleStream
public static DoubleStream generate(DoubleSupplier s)
DoubleSupplier
. This is suitable for
generating constant streams, streams of random elements, etc.s
- the DoubleSupplier
for generated elementsDoubleStream
public static DoubleStream concat(DoubleStream a, DoubleStream b)
Implementation Note:
Use caution when constructing streams from repeated concatenation.
Accessing an element of a deeply concatenated stream can result in deep
call chains, or even StackOverflowError
.
Subsequent changes to the sequential/parallel execution mode of the returned stream are not guaranteed to be propagated to the input streams.
a
- the first streamb
- the second streamCopyright © 2015. All rights reserved.