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.
| Modifier and Type | Field and Description |
|---|---|
| private E | element
The only element of this |
| private static final Object | END
A constant used to determine if we are at the end of the iteration. |
| private E |
| Access | Constructor and Description |
|---|---|
| public | SingleElementListIterator(E
The only element of this element)IteratorCreates a new |
| Modifier and Type | Method and Description |
|---|---|
| public void | add(E
the element to insert item)Implements java. |
| public boolean | hasNext()
Implements java. true if this list iterator has more elements when
traversing the list in the forward direction.
|
| public boolean | hasPrevious()
Implements java. true if this list iterator has more elements when
traversing the list in the reverse direction.
|
| public ListIterator | |
| public E | next()
Implements java. |
| public int | nextIndex()
Implements java. next.
|
| public E | previous()
Implements java. |
| public int | previousIndex()
Implements java. previous.
|
| public void | remove()
Implements java. next or previous (optional operation).
|
| public void | set(E
the element with which to replace the last element returned by
item)next or previousImplements java. next or
previous with the specified element (optional operation).
|
| public String |
| element | back to summary |
|---|---|
| private E element The only element of this | |
| END | back to summary |
|---|---|
| private static final Object END A constant used to determine if we are at the end of the iteration. | |
| next | back to summary |
|---|---|
| private E next The element that can be returned by | |
| SingleElementListIterator | back to summary |
|---|---|
| public SingleElementListIterator(E element) Creates a new
| |
| add | back to summary |
|---|---|
| public void add(E item) Implements java. Doc from java. Inserts the specified element into the list (optional operation).
The element is inserted immediately before the element that
would be returned by
| |
| hasNext | back to summary |
|---|---|
| public boolean hasNext() Implements java. Doc from java. Returns
| |
| hasPrevious | back to summary |
|---|---|
| public boolean hasPrevious() Implements java. Doc from java. Returns
| |
| iterator | back to summary |
|---|---|
| public ListIterator | |
| next | back to summary |
|---|---|
| public E next() Implements java. Doc from java. Returns the next element in the list and advances the cursor position.
This method may be called repeatedly to iterate through the list,
or intermixed with calls to
| |
| nextIndex | back to summary |
|---|---|
| public int nextIndex() Implements java. Doc from java. Returns the index of the element that would be returned by a
subsequent call to
| |
| previous | back to summary |
|---|---|
| public E previous() Implements java. Doc from java. Returns the previous element in the list and moves the cursor
position backwards. This method may be called repeatedly to
iterate through the list backwards, or intermixed with calls to
| |
| previousIndex | back to summary |
|---|---|
| public int previousIndex() Implements java. Doc from java. Returns the index of the element that would be returned by a
subsequent call to
| |
| remove | back to summary |
|---|---|
| public void remove() Implements java. Doc from java. Removes from the list the last element that was returned by
| |
| set | back to summary |
|---|---|
| public void set(E item) Implements java. Doc from java. Replaces the last element returned by
| |
| toString | back to summary |
|---|---|
| public String toString() Overrides java. Doc from java. Returns a string representation of the object.
| |