Class EditingBooleanIterator
java.lang.Object
com.github.tommyettinger.ds.support.util.EditingBooleanIterator
- All Implemented Interfaces:
BooleanIterator,Iterator<Boolean>
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
You can change both the Iterator and editor at once using
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 Summary
FieldsModifier and TypeFieldDescriptioncom.github.tommyettinger.function.BooleanPredicate -
Constructor Summary
ConstructorsConstructorDescriptionEditingBooleanIterator(BooleanIterator iterator, com.github.tommyettinger.function.BooleanPredicate editor) -
Method Summary
Modifier and TypeMethodDescriptionbooleanhasNext()booleanReturns the nextbooleanelement in the iteration.voidremove()voidset(BooleanIterator iterator) voidset(BooleanIterator iterator, com.github.tommyettinger.function.BooleanPredicate editor) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.github.tommyettinger.ds.support.util.BooleanIterator
forEachRemaining, nextMethods inherited from interface java.util.Iterator
forEachRemaining
-
Field Details
-
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
-
hasNext
public boolean hasNext() -
nextBoolean
public boolean nextBoolean()Description copied from interface:BooleanIteratorReturns the nextbooleanelement in the iteration.- Specified by:
nextBooleanin interfaceBooleanIterator- Returns:
- the next
booleanelement in the iteration
-
remove
public void remove()
-