Class EditingDoubleIterator

java.lang.Object
com.github.tommyettinger.ds.support.util.EditingDoubleIterator
All Implemented Interfaces:
DoubleIterator, Iterator<Double>

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

    • iterator

      public DoubleIterator iterator
    • editor

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

    • EditingDoubleIterator

      public EditingDoubleIterator()
    • EditingDoubleIterator

      public EditingDoubleIterator(DoubleIterator iterator, com.github.tommyettinger.function.DoubleToDoubleFunction editor)
  • Method Details

    • set

      public void set(DoubleIterator iterator, com.github.tommyettinger.function.DoubleToDoubleFunction editor)
    • set

      public void set(DoubleIterator iterator)
    • hasNext

      public boolean hasNext()
      Specified by:
      hasNext in interface Iterator<Double>
    • nextDouble

      public double nextDouble()
      Description copied from interface: DoubleIterator
      Returns the next double element in the iteration.
      Specified by:
      nextDouble in interface DoubleIterator
      Returns:
      the next double element in the iteration
    • remove

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