Class EditingShortIterator

java.lang.Object
com.github.tommyettinger.ds.support.util.EditingShortIterator
All Implemented Interfaces:
ShortIterator, Iterator<Short>

public class EditingShortIterator extends Object implements ShortIterator
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(ShortIterator, ShortToShortFunction) , and can also just change the Iterator with set(ShortIterator).
  • Field Details

    • iterator

      public ShortIterator iterator
    • editor

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

    • EditingShortIterator

      public EditingShortIterator()
    • EditingShortIterator

      public EditingShortIterator(ShortIterator iterator, com.github.tommyettinger.function.ShortToShortFunction editor)
  • Method Details

    • set

      public void set(ShortIterator iterator, com.github.tommyettinger.function.ShortToShortFunction editor)
    • set

      public void set(ShortIterator iterator)
    • hasNext

      public boolean hasNext()
      Specified by:
      hasNext in interface Iterator<Short>
    • nextShort

      public short nextShort()
      Description copied from interface: ShortIterator
      Returns the next short element in the iteration.
      Specified by:
      nextShort in interface ShortIterator
      Returns:
      the next short element in the iteration
    • remove

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