Class EditingIntIterator

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

public class EditingIntIterator extends Object implements IntIterator
Wraps an Iterator so that it calls a function on each item it would otherwise return, and returns that function's result. If you need to return a different type than what the iterator returns, you can use an AlteringIterator. This has undefined behavior if any items the Iterator could return are modified during iteration.
You can change both the Iterator and editor at once using set(IntIterator, IntToIntFunction) , and can also just change the Iterator with set(IntIterator).
  • Field Details

    • iterator

      public IntIterator iterator
    • editor

      public com.github.tommyettinger.function.IntToIntFunction editor
  • Constructor Details

    • EditingIntIterator

      public EditingIntIterator()
    • EditingIntIterator

      public EditingIntIterator(IntIterator iterator, com.github.tommyettinger.function.IntToIntFunction editor)
  • Method Details

    • set

      public void set(IntIterator iterator, com.github.tommyettinger.function.IntToIntFunction editor)
    • set

      public void set(IntIterator iterator)
    • hasNext

      public boolean hasNext()
      Specified by:
      hasNext in interface Iterator<Integer>
    • nextInt

      public int nextInt()
      Description copied from interface: IntIterator
      Returns the next int element in the iteration.
      Specified by:
      nextInt in interface IntIterator
      Returns:
      the next int element in the iteration
    • remove

      public void remove()
      Specified by:
      remove in interface Iterator<Integer>