PrimitiveIterator (Java SE 17 & JDK 17)
- Type Parameters:
T- the type of elements returned by this PrimitiveIterator. The type must be a wrapper type for a primitive type, such asIntegerfor the primitiveinttype.T_CONS- the type of primitive consumer. The type must be a primitive specialization ofConsumerforT, such asIntConsumerforInteger.
- All Superinterfaces:
Iterator<T>
- All Known Subinterfaces:
PrimitiveIterator.OfDouble,PrimitiveIterator.OfInt,PrimitiveIterator.OfLong
public interface PrimitiveIterator<T,
- Implementation Note:
- If the boolean system property
org.openjdk.java.util.stream.tripwireis set totruethen diagnostic warnings are reported if boxing of primitive values occur when operating on primitive subtype specializations. - Since:
- 1.8
-
Nested Class Summary
Nested Classes
static interfaceAn Iterator specialized for
doublevalues.static interfaceAn Iterator specialized for
intvalues.static interfaceAn Iterator specialized for
longvalues. -
Method Summary
voidPerforms the given action for each remaining element until all elements have been processed or the action throws an exception.
-
Method Details
-
forEachRemaining
void forEachRemaining
(T_CONS action) 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.
The behavior of an iterator is unspecified if the action modifies the source of elements in any way (even by calling the
removemethod or other mutator methods ofIteratorsubtypes), unless an overriding class has specified a concurrent modification policy.Subsequent behavior of an iterator is unspecified if the action throws an exception.
- Parameters:
action- The action to be performed for each element- Throws:
NullPointerException- if the specified action is null
-