Modifier and Type | Method and Description |
---|---|
static IntStream.Builder |
builder()
Returns a builder for an
IntStream . |
static IntStream |
concat(IntStream a,
IntStream 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 IntStream |
dropWhile(IntStream stream,
IntPredicate 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 IntStream |
empty()
Returns an empty sequential
IntStream . |
static IntStream |
generate(IntSupplier s)
Returns an infinite sequential unordered stream where each element is
generated by the provided
IntSupplier . |
static IntStream |
iterate(int seed,
IntUnaryOperator f)
Returns an infinite sequential ordered
IntStream 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 IntStream |
of(int... values)
Returns a sequential ordered stream whose elements are the specified values.
|
static IntStream |
of(int t)
Returns a sequential
IntStream containing a single element. |
static IntStream |
range(int startInclusive,
int endExclusive)
Returns a sequential ordered
IntStream from startInclusive
(inclusive) to endExclusive (exclusive) by an incremental step of
1 . |
static IntStream |
rangeClosed(int startInclusive,
int endInclusive)
Returns a sequential ordered
IntStream from startInclusive
(inclusive) to endInclusive (inclusive) by an incremental step of
1 . |
static IntStream |
takeWhile(IntStream stream,
IntPredicate 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 IntStream takeWhile(IntStream stream, IntPredicate 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 IntStream dropWhile(IntStream stream, IntPredicate 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 IntStream.Builder builder()
IntStream
.public static IntStream empty()
IntStream
.public static IntStream of(int t)
IntStream
containing a single element.t
- the single elementpublic static IntStream of(int... values)
values
- the elements of the new streampublic static IntStream iterate(int seed, IntUnaryOperator f)
IntStream
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 IntStream
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 elementIntStream
public static IntStream generate(IntSupplier s)
IntSupplier
. This is suitable for
generating constant streams, streams of random elements, etc.s
- the IntSupplier
for generated elementsIntStream
public static IntStream range(int startInclusive, int endExclusive)
IntStream
from startInclusive
(inclusive) to endExclusive
(exclusive) by an incremental step of
1
.
API Note:
An equivalent sequence of increasing values can be produced
sequentially using a for
loop as follows:
for (int i = startInclusive; i < endExclusive ; i++) { ... }
startInclusive
- the (inclusive) initial valueendExclusive
- the exclusive upper boundIntStream
for the range of int
elementspublic static IntStream rangeClosed(int startInclusive, int endInclusive)
IntStream
from startInclusive
(inclusive) to endInclusive
(inclusive) by an incremental step of
1
.
API Note:
An equivalent sequence of increasing values can be produced
sequentially using a for
loop as follows:
for (int i = startInclusive; i <= endInclusive ; i++) { ... }
startInclusive
- the (inclusive) initial valueendInclusive
- the inclusive upper boundIntStream
for the range of int
elementspublic static IntStream concat(IntStream a, IntStream 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.