PrimitiveIterator

A base type for primitive specializations of Iterator. Specialized subtypes are provided for int, long, and double values.

The specialized subtype default implementations of Iterator.next and Iterator.forEachRemaining box primitive values to instances of their corresponding wrapper class. Such boxing may offset any advantages gained when using the primitive specializations. To avoid boxing, the corresponding primitive-based methods should be used. For example, PrimitiveIterator.OfInt.nextInt and PrimitiveIterator.OfInt.forEachRemaining should be used in preference to PrimitiveIterator.OfInt.next and PrimitiveIterator.OfInt.forEachRemaining.

Iteration of primitive values using boxing-based methods next() and Iterator.forEachRemaining, does not affect the order in which the values, transformed to boxed values, are encountered.

Since

1.8

Parameters

the type of primitive consumer. The type must be a primitive specialization of java.util.function.Consumer for T, such as java.util.function.IntConsumer for Integer.

Inheritors

Types

Link copied to clipboard

An Iterator specialized for double values.

Link copied to clipboard
interface OfInt : PrimitiveIterator<Int, (Int) -> Unit>

An Iterator specialized for int values.

Link copied to clipboard
interface OfLong : PrimitiveIterator<Long, (Long) -> Unit>

An Iterator specialized for long values.

Functions

Link copied to clipboard
abstract fun forEachRemaining(action: T_CONS)

Performs the given action for each remaining element until all elements have been processed or the action throws an exception. Actions are performed in the order of iteration, if that order is specified. Exceptions thrown by the action are relayed to the caller.

Link copied to clipboard
expect abstract operator fun hasNext(): Boolean
Link copied to clipboard
abstract operator fun next(): T
Link copied to clipboard
expect abstract fun remove()