Class EditingLongIterator

java.lang.Object
com.github.tommyettinger.ds.support.util.EditingLongIterator
All Implemented Interfaces:
LongIterator, Iterator<Long>

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

    • iterator

      public LongIterator iterator
    • editor

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

    • EditingLongIterator

      public EditingLongIterator()
    • EditingLongIterator

      public EditingLongIterator(LongIterator iterator, com.github.tommyettinger.function.LongToLongFunction editor)
  • Method Details

    • set

      public void set(LongIterator iterator, com.github.tommyettinger.function.LongToLongFunction editor)
    • set

      public void set(LongIterator iterator)
    • hasNext

      public boolean hasNext()
      Specified by:
      hasNext in interface Iterator<Long>
    • nextLong

      public long nextLong()
      Description copied from interface: LongIterator
      Returns the next long element in the iteration.
      Specified by:
      nextLong in interface LongIterator
      Returns:
      the next long element in the iteration
    • remove

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