public class SingletonIterator<E> extends Objectimplements ResettableIterator <E>
SingletonIterator is an
Iterator over a single object instance.
| Constructor and Description |
|---|
SingletonIterator(E object)
Constructs a new
SingletonIterator where
remove is a permitted operation.
|
SingletonIterator(E object, boolean removeAllowed)
Constructs a new
SingletonIterator optionally choosing if
remove is a permitted operation.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
hasNext()
Is another object available from the iterator?
|
E |
next()
Get the next object from the iterator.
|
void |
remove()
Remove the object from this iterator.
|
void |
reset()
Reset the iterator to the start.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitforEachRemainingpublic SingletonIterator(E object)
SingletonIterator where
remove is a permitted operation.
object - the single object to return from the iterator
public SingletonIterator(E object, boolean removeAllowed)
SingletonIterator optionally choosing if
remove is a permitted operation.
object - the single object to return from the iterator
removeAllowed - true if remove is allowed
public boolean hasNext()
This returns true if the single object hasn't been returned yet.
public E next()
This returns the single object if it hasn't been returned yet.
next in interface
Iterator<E>
NoSuchElementException - if the single object has already been returned
public void remove()
remove in interface
Iterator<E>
IllegalStateException - if the
next method has not yet been called, or the
remove method has already been called after the last call to the
next method.
UnsupportedOperationException - if remove is not supported
public void reset()