public class SingleElementListIterator<E> extends Object implements ListIterator<E>
SingleElementListIterator
holds a single element and returns it with the first
call to next()
, at which point it will return false
to any subsequent call
to hasNext()
. Likewise, it will return false
to a call to hasPrevious()
until a call to next()
, at which point a call to previous()
will return the
single element.Constructor and Description |
---|
SingleElementListIterator(E element)
Creates a new
SingleElementListIterator that returns only the specified element. |
Modifier and Type | Method and Description |
---|---|
void |
add(E item) |
boolean |
hasNext() |
boolean |
hasPrevious() |
ListIterator<E> |
iterator() |
E |
next() |
int |
nextIndex() |
E |
previous() |
int |
previousIndex() |
void |
remove() |
void |
set(E item) |
String |
toString() |
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
forEachRemaining
public SingleElementListIterator(E element)
SingleElementListIterator
that returns only the specified element.element
- The only element of this Iterator
public void add(E item)
add
in interface ListIterator<E>
public boolean hasNext()
public boolean hasPrevious()
hasPrevious
in interface ListIterator<E>
public ListIterator<E> iterator()
public E next()
public int nextIndex()
nextIndex
in interface ListIterator<E>
public E previous()
previous
in interface ListIterator<E>
public int previousIndex()
previousIndex
in interface ListIterator<E>
public void remove()
public void set(E item)
set
in interface ListIterator<E>
public String toString()
toString
in class Object
Object.toString()
EclipseLink 2.6.3, "build v20160428-59c81c5" API Reference