Class EditingCharIterator

java.lang.Object
com.github.tommyettinger.ds.support.util.EditingCharIterator
All Implemented Interfaces:
CharIterator, Iterator<Character>

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

    • iterator

      public CharIterator iterator
    • editor

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

    • EditingCharIterator

      public EditingCharIterator()
    • EditingCharIterator

      public EditingCharIterator(CharIterator iterator, com.github.tommyettinger.function.CharToCharFunction editor)
  • Method Details

    • set

      public void set(CharIterator iterator, com.github.tommyettinger.function.CharToCharFunction editor)
    • set

      public void set(CharIterator iterator)
    • hasNext

      public boolean hasNext()
      Specified by:
      hasNext in interface Iterator<Character>
    • nextChar

      public char nextChar()
      Description copied from interface: CharIterator
      Returns the next char element in the iteration.
      Specified by:
      nextChar in interface CharIterator
      Returns:
      the next char element in the iteration
    • remove

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