Class PointNIntIterator

java.lang.Object
com.github.yellowstonegames.grid.PointNIntIterator
All Implemented Interfaces:
com.github.tommyettinger.ds.support.util.IntIterator, Iterator<Integer>

public class PointNIntIterator extends Object implements com.github.tommyettinger.ds.support.util.IntIterator
An IntIterator that iterates over the components in a PointNInt using PointNInt.get(int).
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    int
    Which index this will return next.
    The PointNInt this can iterate through.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Constructs a new PointNIntIterator over the given PointNInt that starts at index 0.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    Returns true if the iteration has more elements.
    int
    Returns the next int element in the iteration.
    void
     
    void
    set(int newValue)
    After nextInt() has been called, you can call this to change the value at the same position last returned by nextInt().

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface com.github.tommyettinger.ds.support.util.IntIterator

    forEachRemaining, next

    Methods inherited from interface Iterator

    forEachRemaining, remove
  • Field Details

    • pt

      public PointNInt<?,?> pt
      The PointNInt this can iterate through.
    • index

      public int index
      Which index this will return next.
  • Constructor Details

    • PointNIntIterator

      public PointNIntIterator(PointNInt<?,?> pt)
      Constructs a new PointNIntIterator over the given PointNInt that starts at index 0.
      Parameters:
      pt - the PointNInt to iterate over
  • Method Details

    • nextInt

      public int nextInt()
      Returns the next int element in the iteration. Unlike most IntIterator types, this typically won't throw an Exception if the iterator is exhausted. You should still use hasNext() to determine when the iterator has exhausted the available items.
      Specified by:
      nextInt in interface com.github.tommyettinger.ds.support.util.IntIterator
      Returns:
      the next int element in the iteration
    • hasNext

      public boolean hasNext()
      Returns true if the iteration has more elements. (In other words, if nextInt()) has been called fewer times than PointN.rank()).
      Specified by:
      hasNext in interface Iterator<Integer>
      Returns:
      true if the iteration has more elements
    • set

      public void set(int newValue)
      After nextInt() has been called, you can call this to change the value at the same position last returned by nextInt(). If nextInt() has not yet been called, this does not have defined behavior, and is permitted to throw an Exception.
      Parameters:
      newValue - the value to use at the last returned index
    • reset

      public void reset()