Interface IntIterator

All Superinterfaces:
Iterator<Integer>
All Known Implementing Classes:
EditingIntIterator, EnumIntMap.ValueIterator, FilteringIntIterator, IntDeque.IntDequeIterator, IntFloatMap.KeyIterator, IntIntMap.KeyIterator, IntIntMap.ValueIterator, IntList.IntListIterator, IntLongMap.KeyIterator, IntObjectMap.KeyIterator, IntOrderedSet.IntOrderedSetIterator, IntSet.IntSetIterator, LimitingIntIterator, LongIntMap.ValueIterator, ObjectIntMap.ValueIterator, OffsetBitSet.OffsetBitSetIterator, StridingIntIterator

public interface IntIterator extends Iterator<Integer>
An Iterator specialized for int values. This iterates over primitive ints using nextInt().
This is roughly equivalent to IntIterator in Java 8, and is present here so environments don't fully support Java 8 APIs (such as RoboVM) can use it.
This interface is closely based on IntIterator 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 Type
    Method
    Description
    default void
    forEachRemaining(com.github.tommyettinger.function.IntConsumer action)
    Performs the given action for each remaining element until all elements have been processed or the action throws an exception.
    default Integer
    int
    Returns the next int element in the iteration.

    Methods inherited from interface java.util.Iterator

    forEachRemaining, hasNext, remove
  • Method Details

    • nextInt

      int nextInt()
      Returns the next int element in the iteration.
      Returns:
      the next int element in the iteration
      Throws:
      NoSuchElementException - if the iteration has no more elements
    • forEachRemaining

      default void forEachRemaining(com.github.tommyettinger.function.IntConsumer 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(nextInt());
       
    • next

      default Integer next()
      Specified by:
      next in interface Iterator<Integer>
      "Implementation Requirements"
      The default implementation boxes the result of calling nextInt(), and returns that boxed result.