E
- The element type.public abstract class LookaheadIterator<E> extends Object implements Iterator<E>
Iterator
implementations that need to calculate the next value in order to let Iterator.hasNext()
return whether
or not there is a next value.
Sub classes should implement findNext(Consumer)
to find the next element. Furthermore, sub classes should support the
Iterator.remove()
operation should also override remove()
.
Modifier | Constructor and Description |
---|---|
protected |
LookaheadIterator()
Creates a new lookahead iterator.
|
Modifier and Type | Method and Description |
---|---|
protected abstract void |
findNext(Consumer<E> next)
Tries to finds the next element.
|
boolean |
hasNext() |
E |
next() |
void |
remove() |
protected void |
remove(E element)
Removes the latest element returned by
Iterator.next() . |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
forEachRemaining
protected LookaheadIterator()
protected abstract void findNext(Consumer<E> next)
next
- The consumer to call with the next element.protected void remove(E element)
Iterator.next()
.UnsupportedOperationException
.element
- The element to remove.Copyright © 2022. All rights reserved.