ArraySpliterator

A Spliterator designed for use by sources that traverse and split elements maintained in an unmodifiable Array. Mimics Spliterators.ArraySpliterator.

Constructors

Link copied to clipboard
constructor(array: Array<T?>, additionalCharacteristics: Int)

Creates a spliterator covering all of the given array. Its size is known exactly and it reports SIZED and SUBSIZED.

constructor(array: Array<T?>, origin: Int, fence: Int, additionalCharacteristics: Int)

Creates a spliterator covering the given array and range. Its size is known exactly and it reports SIZED and SUBSIZED.

Functions

Link copied to clipboard
open override fun characteristics(): Int

Returns a set of characteristics of this Spliterator and its elements. The result is represented as ORed values from the constants defined in the companion object (ORDERED, DISTINCT, etc.).

Link copied to clipboard
open override fun estimateSize(): Long

Returns an estimate of the number of elements that would be encountered by a forEachRemaining traversal, or Long.MAX_VALUE if infinite, unknown, or too expensive to compute.

Link copied to clipboard
open override fun forEachRemaining(action: (T) -> Unit)

Performs the given action for each remaining element, sequentially, until all elements have been processed or the action throws an exception. If this Spliterator is ORDERED, actions are performed in encounter order. Exceptions thrown by the action are relayed to the caller.

Link copied to clipboard
open override fun getComparator(): Comparator<in T>?

If SORTED by a Comparator, returns that Comparator. If SORTED in natural order, returns null. Otherwise (not SORTED), throws IllegalStateException.

Link copied to clipboard

Convenience method returning estimateSize if SIZED, else -1L.

Link copied to clipboard
open fun hasCharacteristics(characteristics: Int): Boolean

Returns true if this Spliterator's characteristics contain all of the given characteristics.

Link copied to clipboard
open override fun tryAdvance(action: (T) -> Unit): Boolean

If a remaining element exists: performs the given action on it, returning true; else returns false. If this Spliterator is ORDERED, the action is performed on the next element in encounter order. Exceptions thrown by the action are relayed to the caller.

Link copied to clipboard
open override fun trySplit(): Spliterator<T>?

If this spliterator can be partitioned, returns a Spliterator covering elements that will, upon return, not be covered by this Spliterator.