public final class StreamSupport extends Object
This class is mostly for library writers presenting stream views of data structures; most static stream methods intended for end users are in the various Stream classes.
| Modifier and Type | Method and Description |
|---|---|
static DoubleStream |
doubleStream(Spliterator
Creates a new sequential or parallel
DoubleStream from a
Spliterator.OfDouble.
|
static DoubleStream |
doubleStream(Supplier
Creates a new sequential or parallel
DoubleStream from a
Supplier of
Spliterator.OfDouble.
|
static IntStream |
intStream(Spliterator
Creates a new sequential or parallel
IntStream from a
Spliterator.OfInt.
|
static IntStream |
intStream(Supplier
Creates a new sequential or parallel
IntStream from a
Supplier of
Spliterator.OfInt.
|
static LongStream |
longStream(Spliterator
Creates a new sequential or parallel
LongStream from a
Spliterator.OfLong.
|
static LongStream |
longStream(Supplier
Creates a new sequential or parallel
LongStream from a
Supplier of
Spliterator.OfLong.
|
static <T> Stream |
stream(Spliterator
Creates a new sequential or parallel
Stream from a
Spliterator.
|
static <T> Stream |
stream(Supplier
Creates a new sequential or parallel
Stream from a
Supplier of
Spliterator.
|
public static <T> Stream<T> stream(Spliterator <T> spliterator, boolean parallel)
Stream from a
Spliterator.
The spliterator is only traversed, split, or queried for estimated size after the terminal operation of the stream pipeline commences.
It is strongly recommended the spliterator report a characteristic of IMMUTABLE or CONCURRENT, or be late-binding. Otherwise, stream(java.util.function.Supplier, int, boolean) should be used to reduce the scope of potential interference with the source. See Non-Interference for more details.
T - the type of stream elements
spliterator - a
Spliterator describing the stream elements
parallel - if
true then the returned stream is a parallel stream; if
false the returned stream is a sequential stream.
Stream
public static <T> Stream<T> stream(Supplier <? extends Spliterator <T>> supplier, int characteristics, boolean parallel)
Stream from a
Supplier of
Spliterator.
The Supplier method will be invoked on the supplier no more than once, and only after the terminal operation of the stream pipeline commences.
For spliterators that report a characteristic of IMMUTABLE or CONCURRENT, or that are late-binding, it is likely more efficient to use stream(java.util.Spliterator, boolean) instead.
The use of a Supplier in this form provides a level of indirection that reduces the scope of potential interference with the source. Since the supplier is only invoked after the terminal operation commences, any modifications to the source up to the start of the terminal operation are reflected in the stream result. See Non-Interference for more details.
T - the type of stream elements
supplier - a
Supplier of a
Spliterator
characteristics - Spliterator characteristics of the supplied
Spliterator. The characteristics must be equal to
supplier.get().characteristics(), otherwise undefined behavior may occur when terminal operation commences.
parallel - if
true then the returned stream is a parallel stream; if
false the returned stream is a sequential stream.
Stream
stream(java.util.Spliterator, boolean)
public static IntStreamintStream(Spliterator .OfInt spliterator, boolean parallel)
IntStream from a
Spliterator.OfInt.
The spliterator is only traversed, split, or queried for estimated size after the terminal operation of the stream pipeline commences.
It is strongly recommended the spliterator report a characteristic of IMMUTABLE or CONCURRENT, or be late-binding. Otherwise, intStream(java.util.function.Supplier, int, boolean) should be used to reduce the scope of potential interference with the source. See Non-Interference for more details.
spliterator - a
Spliterator.OfInt describing the stream elements
parallel - if
true then the returned stream is a parallel stream; if
false the returned stream is a sequential stream.
IntStream
public static IntStreamintStream(Supplier <? extends Spliterator .OfInt > supplier, int characteristics, boolean parallel)
IntStream from a
Supplier of
Spliterator.OfInt.
The Supplier method will be invoked on the supplier no more than once, and only after the terminal operation of the stream pipeline commences.
For spliterators that report a characteristic of IMMUTABLE or CONCURRENT, or that are late-binding, it is likely more efficient to use intStream(java.util.Spliterator.OfInt, boolean) instead.
The use of a Supplier in this form provides a level of indirection that reduces the scope of potential interference with the source. Since the supplier is only invoked after the terminal operation commences, any modifications to the source up to the start of the terminal operation are reflected in the stream result. See Non-Interference for more details.
supplier - a
Supplier of a
Spliterator.OfInt
characteristics - Spliterator characteristics of the supplied
Spliterator.OfInt. The characteristics must be equal to
supplier.get().characteristics(), otherwise undefined behavior may occur when terminal operation commences.
parallel - if
true then the returned stream is a parallel stream; if
false the returned stream is a sequential stream.
IntStream
intStream(java.util.Spliterator.OfInt, boolean)
public static LongStreamlongStream(Spliterator .OfLong spliterator, boolean parallel)
LongStream from a
Spliterator.OfLong.
The spliterator is only traversed, split, or queried for estimated size after the terminal operation of the stream pipeline commences.
It is strongly recommended the spliterator report a characteristic of IMMUTABLE or CONCURRENT, or be late-binding. Otherwise, longStream(java.util.function.Supplier, int, boolean) should be used to reduce the scope of potential interference with the source. See Non-Interference for more details.
spliterator - a
Spliterator.OfLong describing the stream elements
parallel - if
true then the returned stream is a parallel stream; if
false the returned stream is a sequential stream.
LongStream
public static LongStreamlongStream(Supplier <? extends Spliterator .OfLong > supplier, int characteristics, boolean parallel)
LongStream from a
Supplier of
Spliterator.OfLong.
The Supplier method will be invoked on the supplier no more than once, and only after the terminal operation of the stream pipeline commences.
For spliterators that report a characteristic of IMMUTABLE or CONCURRENT, or that are late-binding, it is likely more efficient to use longStream(java.util.Spliterator.OfLong, boolean) instead.
The use of a Supplier in this form provides a level of indirection that reduces the scope of potential interference with the source. Since the supplier is only invoked after the terminal operation commences, any modifications to the source up to the start of the terminal operation are reflected in the stream result. See Non-Interference for more details.
supplier - a
Supplier of a
Spliterator.OfLong
characteristics - Spliterator characteristics of the supplied
Spliterator.OfLong. The characteristics must be equal to
supplier.get().characteristics(), otherwise undefined behavior may occur when terminal operation commences.
parallel - if
true then the returned stream is a parallel stream; if
false the returned stream is a sequential stream.
LongStream
longStream(java.util.Spliterator.OfLong, boolean)
public static DoubleStreamdoubleStream(Spliterator .OfDouble spliterator, boolean parallel)
DoubleStream from a
Spliterator.OfDouble.
The spliterator is only traversed, split, or queried for estimated size after the terminal operation of the stream pipeline commences.
It is strongly recommended the spliterator report a characteristic of IMMUTABLE or CONCURRENT, or be late-binding. Otherwise, doubleStream(java.util.function.Supplier, int, boolean) should be used to reduce the scope of potential interference with the source. See Non-Interference for more details.
spliterator - A
Spliterator.OfDouble describing the stream elements
parallel - if
true then the returned stream is a parallel stream; if
false the returned stream is a sequential stream.
DoubleStream
public static DoubleStreamdoubleStream(Supplier <? extends Spliterator .OfDouble > supplier, int characteristics, boolean parallel)
DoubleStream from a
Supplier of
Spliterator.OfDouble.
The Supplier method will be invoked on the supplier no more than once, and only after the terminal operation of the stream pipeline commences.
For spliterators that report a characteristic of IMMUTABLE or CONCURRENT, or that are late-binding, it is likely more efficient to use doubleStream(java.util.Spliterator.OfDouble, boolean) instead.
The use of a Supplier in this form provides a level of indirection that reduces the scope of potential interference with the source. Since the supplier is only invoked after the terminal operation commences, any modifications to the source up to the start of the terminal operation are reflected in the stream result. See Non-Interference for more details.
supplier - A
Supplier of a
Spliterator.OfDouble
characteristics - Spliterator characteristics of the supplied
Spliterator.OfDouble. The characteristics must be equal to
supplier.get().characteristics(), otherwise undefined behavior may occur when terminal operation commences.
parallel - if
true then the returned stream is a parallel stream; if
false the returned stream is a sequential stream.
DoubleStream
doubleStream(java.util.Spliterator.OfDouble, boolean)