public final class IntStreams
extends java.lang.Object
IntStream
interface.Modifier and Type | Class and Description |
---|---|
static class |
IntStreams.J8Builder
A place for static default implementations of the new Java 8
default interface methods and static interface methods in the
IntStream.Builder interface. |
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 |
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 . |
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 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 StackOverflowException
.
a
- the first streamb
- the second stream