Added in API level 24

StreamSupport

class StreamSupport
kotlin.Any
   ↳ java.util.stream.StreamSupport

Low-level utility methods for creating and manipulating streams.

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.

Summary

Public methods
static DoubleStream!
doubleStream(spliterator: Spliterator.OfDouble!, parallel: Boolean)

Creates a new sequential or parallel DoubleStream from a Spliterator.OfDouble.

static DoubleStream!
doubleStream(supplier: Supplier<out Spliterator.OfDouble!>!, characteristics: Int, parallel: Boolean)

Creates a new sequential or parallel DoubleStream from a Supplier of Spliterator.OfDouble.

static IntStream!
intStream(spliterator: Spliterator.OfInt!, parallel: Boolean)

Creates a new sequential or parallel IntStream from a Spliterator.OfInt.

static IntStream!
intStream(supplier: Supplier<out Spliterator.OfInt!>!, characteristics: Int, parallel: Boolean)

Creates a new sequential or parallel IntStream from a Supplier of Spliterator.OfInt.

static LongStream!
longStream(spliterator: Spliterator.OfLong!, parallel: Boolean)

Creates a new sequential or parallel LongStream from a Spliterator.OfLong.

static LongStream!
longStream(supplier: Supplier<out Spliterator.OfLong!>!, characteristics: Int, parallel: Boolean)

Creates a new sequential or parallel LongStream from a Supplier of Spliterator.OfLong.

static Stream<T>!
stream(spliterator: Spliterator<T>!, parallel: Boolean)

Creates a new sequential or parallel Stream from a Spliterator.

static Stream<T>!
stream(supplier: Supplier<out Spliterator<T>!>!, characteristics: Int, parallel: Boolean)

Creates a new sequential or parallel Stream from a Supplier of Spliterator.

Public methods

doubleStream

Added in API level 24
static fun doubleStream(
    spliterator: Spliterator.OfDouble!,
    parallel: Boolean
): DoubleStream!

Creates a new sequential or 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.

Parameters
spliterator Spliterator.OfDouble!: A Spliterator.OfDouble describing the stream elements
parallel Boolean: if true then the returned stream is a parallel stream; if false the returned stream is a sequential stream.
Return
DoubleStream! a new sequential or parallel DoubleStream

doubleStream

Added in API level 24
static fun doubleStream(
    supplier: Supplier<out Spliterator.OfDouble!>!,
    characteristics: Int,
    parallel: Boolean
): DoubleStream!

Creates a new sequential or parallel DoubleStream from a Supplier of Spliterator.OfDouble.

The Supplier#get() 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.

Parameters
supplier Supplier<out Spliterator.OfDouble!>!: A Supplier of a Spliterator.OfDouble
characteristics Int: 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 Boolean: if true then the returned stream is a parallel stream; if false the returned stream is a sequential stream.
Return
DoubleStream! a new sequential or parallel DoubleStream

intStream

Added in API level 24
static fun intStream(
    spliterator: Spliterator.OfInt!,
    parallel: Boolean
): IntStream!

Creates a new sequential or 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.

Parameters
spliterator Spliterator.OfInt!: a Spliterator.OfInt describing the stream elements
parallel Boolean: if true then the returned stream is a parallel stream; if false the returned stream is a sequential stream.
Return
IntStream! a new sequential or parallel IntStream

intStream

Added in API level 24
static fun intStream(
    supplier: Supplier<out Spliterator.OfInt!>!,
    characteristics: Int,
    parallel: Boolean
): IntStream!

Creates a new sequential or parallel IntStream from a Supplier of Spliterator.OfInt.

The Supplier#get() 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.

Parameters
supplier Supplier<out Spliterator.OfInt!>!: a Supplier of a Spliterator.OfInt
characteristics Int: 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 Boolean: if true then the returned stream is a parallel stream; if false the returned stream is a sequential stream.
Return
IntStream! a new sequential or parallel IntStream

longStream

Added in API level 24
static fun longStream(
    spliterator: Spliterator.OfLong!,
    parallel: Boolean
): LongStream!

Creates a new sequential or 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.

Parameters
spliterator Spliterator.OfLong!: a Spliterator.OfLong describing the stream elements
parallel Boolean: if true then the returned stream is a parallel stream; if false the returned stream is a sequential stream.
Return
LongStream! a new sequential or parallel LongStream

longStream

Added in API level 24
static fun longStream(
    supplier: Supplier<out Spliterator.OfLong!>!,
    characteristics: Int,
    parallel: Boolean
): LongStream!

Creates a new sequential or parallel LongStream from a Supplier of Spliterator.OfLong.

The Supplier#get() 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.

Parameters
supplier Supplier<out Spliterator.OfLong!>!: a Supplier of a Spliterator.OfLong
characteristics Int: 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 Boolean: if true then the returned stream is a parallel stream; if false the returned stream is a sequential stream.
Return
LongStream! a new sequential or parallel LongStream

stream

Added in API level 24
static fun <T : Any!> stream(
    spliterator: Spliterator<T>!,
    parallel: Boolean
): Stream<T>!

Creates a new sequential or 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.

Parameters
<T> the type of stream elements
spliterator Spliterator<T>!: a Spliterator describing the stream elements
parallel Boolean: if true then the returned stream is a parallel stream; if false the returned stream is a sequential stream.
Return
Stream<T>! a new sequential or parallel Stream

stream

Added in API level 24
static fun <T : Any!> stream(
    supplier: Supplier<out Spliterator<T>!>!,
    characteristics: Int,
    parallel: Boolean
): Stream<T>!

Creates a new sequential or parallel Stream from a Supplier of Spliterator.

The Supplier#get() 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.

Parameters
<T> the type of stream elements
supplier Supplier<out Spliterator<T>!>!: a Supplier of a Spliterator
characteristics Int: 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 Boolean: if true then the returned stream is a parallel stream; if false the returned stream is a sequential stream.
Return
Stream<T>! a new sequential or parallel Stream