Interface ShortIterator
- All Known Implementing Classes:
EditingShortIterator,FilteringShortIterator,LimitingShortIterator,ShortDeque.ShortDequeIterator,ShortList.ShortListIterator,StridingShortIterator
An Iterator specialized for
This interface is loosely based on a similar interface in OpenJDK 8. This iterator interface is extremely simple and there's no way to implement it in a way that respects compatibility other than the way OpenJDK 8 does. OpenJDK's license is available here, if it applies at all.
short values.
This iterates over primitive shorts using nextShort().
This interface is loosely based on a similar interface in OpenJDK 8. This iterator interface is extremely simple and there's no way to implement it in a way that respects compatibility other than the way OpenJDK 8 does. OpenJDK's license is available here, if it applies at all.
-
Method Summary
Modifier and TypeMethodDescriptiondefault voidforEachRemaining(com.github.tommyettinger.function.ShortConsumer action) Performs the given action for each remaining element until all elements have been processed or the action throws an exception.default Shortnext()shortReturns the nextshortelement in the iteration.Methods inherited from interface java.util.Iterator
forEachRemaining, hasNext, remove
-
Method Details
-
nextShort
short nextShort()Returns the nextshortelement in the iteration.- Returns:
- the next
shortelement in the iteration - Throws:
NoSuchElementException- if the iteration has no more elements
-
forEachRemaining
default void forEachRemaining(com.github.tommyettinger.function.ShortConsumer 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.- Parameters:
action- The action to be performed for each element- Throws:
NullPointerException- if the specified action is null- "Implementation Requirements"
The default implementation behaves as if:
while (hasNext()) action.accept(nextShort());
-
next
- Specified by:
nextin interfaceIterator<Short>- "Implementation Requirements"
- The default implementation boxes the result of calling
nextShort(), and returns that boxed result.
-