T - the type of elements returned by this PrimitiveIterator. The type must be a wrapper type for a primitive type, such as
Integer for the primitive
int type.
T_CONS - the type of primitive consumer. The type must be a primitive specialization of
Consumer for
T, such as
IntConsumer for
Integer.
public interface PrimitiveIterator<T,T_CONS> extends Iterator<T>
Iterator. Specialized subtypes are provided for
int,
long, and
double values.
The specialized subtype default implementations of Iterator and Iterator 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 and PrimitiveIterator should be used in preference to PrimitiveIterator and PrimitiveIterator.
Iteration of primitive values using boxing-based methods next() and forEachRemaining(), does not affect the order in which the values, transformed to boxed values, are encountered.
| Modifier and Type | Interface and Description |
|---|---|
static interface |
PrimitiveIterator
An Iterator specialized for
double values.
|
static interface |
PrimitiveIterator
An Iterator specialized for
int values.
|
static interface |
PrimitiveIterator
An Iterator specialized for
long values.
|
| Modifier and Type | Method and Description |
|---|---|
void |
forEachRemaining(T_CONS action)
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.
|
forEachRemaining, hasNext, next, removevoid forEachRemaining(T_CONS action)
action - The action to be performed for each element
NullPointerException - if the specified action is null