public class SingletonIterator<E> extends java.lang.Object implements java.util.Iterator<E>, 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. |
public SingletonIterator(E object)
SingletonIterator where remove
is a permitted operation.object - the single object to return from the iteratorpublic SingletonIterator(E object, boolean removeAllowed)
SingletonIterator optionally choosing if
remove is a permitted operation.object - the single object to return from the iteratorremoveAllowed - true if remove is allowedpublic boolean hasNext()
This returns true if the single object hasn't been returned yet.
hasNext in interface java.util.Iterator<E>public E next()
This returns the single object if it hasn't been returned yet.
next in interface java.util.Iterator<E>java.util.NoSuchElementException - if the single object has already
been returnedpublic void remove()
remove in interface java.util.Iterator<E>java.lang.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.java.lang.UnsupportedOperationException - if remove is not supportedpublic void reset()
reset in interface ResettableIterator<E>Copyright © 2001-2013. All Rights Reserved.