E
- is the generic type of the iterated
elements.public abstract class AbstractIterator<E> extends Object implements Iterator<E>
Iterator
interface. It allows to implement an read-only
lookahead Iterator
easier:findNext()
. From your constructor or initializer call
findFirst()
. Iterator
can NOT iterate null
values. Further do NOT forget to call findFirst()
from
your constructor or your iterator will always be empty.Modifier and Type | Field and Description |
---|---|
private E |
next
the next item or
null if done |
Constructor and Description |
---|
AbstractIterator()
The constructor.
|
Modifier and Type | Method and Description |
---|---|
protected void |
findFirst()
This method has to be called from the constructor of the implementing class.
|
protected abstract E |
findNext()
This method tries to find the
next element. |
boolean |
hasNext() |
E |
next() |
void |
remove()
This method will always throw an exception.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
forEachRemaining
private E next
null
if donepublic AbstractIterator()
findFirst()
protected final void findFirst()
protected abstract E findNext()
next
element.null
if done
.public final void remove() throws UnsupportedOperationException
remove
in interface Iterator<E>
UnsupportedOperationException
- whenever this method is called.Iterator.remove()
Copyright © 2001–2016 mmm-Team. All rights reserved.