Client and backend. This class is shared: the same code is compiled into your app and into your server, so everything on this page works in both.

public interface Spliterator<T>

A source of elements that hands them out one at a time, which is what java.util.stream.StreamSupport makes a stream of.

Streams here are sequential, so nothing splits one: trySplit may answer null, and the ones this library makes always do.

Fields

public static final int ORDERED = 16The elements have a defined encounter order.
public static final int DISTINCT = 1No two elements are equal.
public static final int SORTED = 4The elements are in the order getComparator() gives.
public static final int SIZED = 64estimateSize() is exact.
public static final int NONNULL = 256No element is null.
public static final int IMMUTABLE = 1024The source cannot be changed.
public static final int CONCURRENT = 4096The source may be changed safely while it is read.
public static final int SUBSIZED = 16384The parts a split makes are sized too.

Methods

public abstract boolean tryAdvance(Consumer<? super T> action)Hands the next element to action and answers true, or answers false when there is none.
public default void forEachRemaining(Consumer<? super T> action)Hands every remaining element to action, in order.
public abstract Spliterator<T> trySplit()A part of the elements to be read separately, or null when this source does not split.
public abstract long estimateSize()How many elements remain, Long.MAX_VALUE when that is not known.
public default long getExactSizeIfKnown()estimateSize() when the source is SIZED, -1 otherwise.
public abstract int characteristics()The characteristics of this source, as a set of the bits declared here.
public default boolean hasCharacteristics(int characteristics)Whether every bit of characteristics is one of this source’s.
public default Comparator<? super T> getComparator()The order of a SORTED source, null for the natural order.

Field details

ORDERED

public static final int ORDERED = 16
The elements have a defined encounter order.

DISTINCT

public static final int DISTINCT = 1
No two elements are equal.

SORTED

public static final int SORTED = 4
The elements are in the order getComparator() gives.

SIZED

public static final int SIZED = 64
estimateSize() is exact.

NONNULL

public static final int NONNULL = 256
No element is null.

IMMUTABLE

public static final int IMMUTABLE = 1024
The source cannot be changed.

CONCURRENT

public static final int CONCURRENT = 4096
The source may be changed safely while it is read.

SUBSIZED

public static final int SUBSIZED = 16384
The parts a split makes are sized too.

Method details

tryAdvance

public abstract boolean tryAdvance(Consumer<? super T> action)
Hands the next element to action and answers true, or answers false when there is none.

forEachRemaining

public default void forEachRemaining(Consumer<? super T> action)
Hands every remaining element to action, in order.

trySplit

public abstract Spliterator<T> trySplit()
A part of the elements to be read separately, or null when this source does not split.

estimateSize

public abstract long estimateSize()
How many elements remain, Long.MAX_VALUE when that is not known.

getExactSizeIfKnown

public default long getExactSizeIfKnown()
estimateSize() when the source is SIZED, -1 otherwise.

characteristics

public abstract int characteristics()
The characteristics of this source, as a set of the bits declared here.

hasCharacteristics

public default boolean hasCharacteristics(int characteristics)
Whether every bit of characteristics is one of this source’s.

getComparator

public default Comparator<? super T> getComparator()
The order of a SORTED source, null for the natural order.

Throws

IllegalStateException
when the source is not sorted