Class EditingByteIterator

java.lang.Object
com.github.tommyettinger.ds.support.util.EditingByteIterator
All Implemented Interfaces:
ByteIterator, Iterator<Byte>

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

    • iterator

      public ByteIterator iterator
    • editor

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

    • EditingByteIterator

      public EditingByteIterator()
    • EditingByteIterator

      public EditingByteIterator(ByteIterator iterator, com.github.tommyettinger.function.ByteToByteFunction editor)
  • Method Details

    • set

      public void set(ByteIterator iterator, com.github.tommyettinger.function.ByteToByteFunction editor)
    • set

      public void set(ByteIterator iterator)
    • hasNext

      public boolean hasNext()
      Specified by:
      hasNext in interface Iterator<Byte>
    • nextByte

      public byte nextByte()
      Description copied from interface: ByteIterator
      Returns the next byte element in the iteration.
      Specified by:
      nextByte in interface ByteIterator
      Returns:
      the next byte element in the iteration
    • remove

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