PrimitiveIterator
interface PrimitiveIterator<T : Any!, T_CONS : Any!> : MutableIterator<T>
| java.util.PrimitiveIterator |
A base type for primitive specializations of Iterator. Specialized subtypes are provided for OfInt, OfLong, and OfDouble values.
The specialized subtype default implementations of Iterator#next and Iterator#forEachRemaining(java.util.function.Consumer) 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(java.util.function.IntConsumer) should be used in preference to PrimitiveIterator.OfInt#next() and PrimitiveIterator.OfInt#forEachRemaining(java.util.function.Consumer).
Iteration of primitive values using boxing-based methods Iterator#next and Iterator#forEachRemaining(java.util.function.Consumer), does not affect the order in which the values, transformed to boxed values, are encountered.
Summary
| Nested classes | |
|---|---|
| abstract |
An Iterator specialized for |
| abstract |
An Iterator specialized for |
| abstract |
An Iterator specialized for |
| Public methods | |
|---|---|
| abstract Unit |
forEachRemaining(action: T_CONS)Performs the given action for each remaining element, in the order elements occur when iterating, until all elements have been processed or the action throws an exception. |
Public methods
forEachRemaining
abstract fun forEachRemaining(action: T_CONS): Unit
Performs the given action for each remaining element, in the order elements occur when iterating, until all elements have been processed or the action throws an exception. Errors or runtime exceptions thrown by the action are relayed to the caller.
| Parameters | |
|---|---|
action |
T_CONS: The action to be performed for each element |
| Exceptions | |
|---|---|
java.lang.NullPointerException |
if the specified action is null |