public final class LongStreams
extends java.lang.Object
LongStream interface.| Modifier and Type | Class and Description |
|---|---|
static class |
LongStreams.J8Builder
A place for static default implementations of the new Java 8
default interface methods and static interface methods in the
LongStream.Builder interface. |
| Modifier and Type | Method and Description |
|---|---|
static LongStream.Builder |
builder()
Returns a builder for a
LongStream. |
static LongStream |
concat(LongStream a,
LongStream 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 LongStream |
empty()
Returns an empty sequential
LongStream. |
static LongStream |
generate(LongSupplier s)
Returns an infinite sequential unordered stream where each element is
generated by the provided
LongSupplier. |
static LongStream |
iterate(long seed,
LongUnaryOperator f)
Returns an infinite sequential ordered
LongStream 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 LongStream |
of(long... values)
Returns a sequential ordered stream whose elements are the specified values.
|
static LongStream |
of(long t)
Returns a sequential
LongStream containing a single element. |
static LongStream |
range(long startInclusive,
long endExclusive)
Returns a sequential ordered
LongStream from startInclusive
(inclusive) to endExclusive (exclusive) by an incremental step of
1. |
static LongStream |
rangeClosed(long startInclusive,
long endInclusive)
Returns a sequential ordered
LongStream from startInclusive
(inclusive) to endInclusive (inclusive) by an incremental step of
1. |
public static LongStream.Builder builder()
LongStream.public static LongStream empty()
LongStream.public static LongStream of(long t)
LongStream containing a single element.t - the single elementpublic static LongStream of(long... values)
values - the elements of the new streampublic static LongStream iterate(long seed, LongUnaryOperator f)
LongStream 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 LongStream 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 elementLongStreampublic static LongStream generate(LongSupplier s)
LongSupplier. This is suitable for
generating constant streams, streams of random elements, etc.s - the LongSupplier for generated elementsLongStreampublic static LongStream range(long startInclusive, long endExclusive)
LongStream 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 (long i = startInclusive; i < endExclusive ; i++) { ... }
startInclusive - the (inclusive) initial valueendExclusive - the exclusive upper boundLongStream for the range of long
elementspublic static LongStream rangeClosed(long startInclusive, long endInclusive)
LongStream 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 (long i = startInclusive; i <= endInclusive ; i++) { ... }
startInclusive - the (inclusive) initial valueendInclusive - the inclusive upper boundLongStream for the range of long
elementspublic static LongStream concat(LongStream a, LongStream 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