Class EditingBooleanIterator

java.lang.Object
com.github.tommyettinger.ds.support.util.EditingBooleanIterator
All Implemented Interfaces:
BooleanIterator, Iterator<Boolean>

public class EditingBooleanIterator extends Object implements BooleanIterator
Wraps an Iterator so that it calls a function on each item it would otherwise return, and returns that function's result. The function in this is actually a predicate, since all function types in Funderby that return booleans are considered predicates. 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(BooleanIterator, BooleanPredicate) , and can also just change the Iterator with set(BooleanIterator).
  • Field Details

    • iterator

      public BooleanIterator iterator
    • editor

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

    • EditingBooleanIterator

      public EditingBooleanIterator()
    • EditingBooleanIterator

      public EditingBooleanIterator(BooleanIterator iterator, com.github.tommyettinger.function.BooleanPredicate editor)
  • Method Details

    • set

      public void set(BooleanIterator iterator, com.github.tommyettinger.function.BooleanPredicate editor)
    • set

      public void set(BooleanIterator iterator)
    • hasNext

      public boolean hasNext()
      Specified by:
      hasNext in interface Iterator<Boolean>
    • nextBoolean

      public boolean nextBoolean()
      Description copied from interface: BooleanIterator
      Returns the next boolean element in the iteration.
      Specified by:
      nextBoolean in interface BooleanIterator
      Returns:
      the next boolean element in the iteration
    • remove

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