|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectnet.sf.molae.pipe.basic.AbstractListIterator<E>
public abstract class AbstractListIterator<E>
This class provides a skeletal implementation of the
ListIterator interface,
to minimize the effort required to implement this interface.
It provides an int property that stores the index of the actual
cursor position.
For immutable lists only hasNext() and get() have to be
implemented.
Instead of get(),
next() and previous() can be implemented directly.
For mutable lists use ListBasedListIterator.
| Constructor Summary | |
|---|---|
AbstractListIterator()
|
|
| Method Summary | |
|---|---|
void |
add(E o)
This implementation always throws an UnsupportedOperationException. |
protected void |
forwardTo(int index)
Calls next() until cursor equals specified index. |
protected E |
get()
This method can be used as a common body for next() and previous(). |
abstract boolean |
hasNext()
|
boolean |
hasPrevious()
Tests if the value of the cursor is zero. |
E |
next()
This implementation calls get() and increments the cursor. |
int |
nextIndex()
This implementation returns the value of the cursor. |
E |
previous()
This implementation decrements the cursor and calls get(). |
int |
previousIndex()
This implementation returns the value of the cursor-1. |
void |
remove()
This implementation always throws an UnsupportedOperationException. |
void |
set(E o)
This implementation always throws an UnsupportedOperationException. |
protected void |
setCursor(int newCursor)
Replaces the value of the cursor with the specified value. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public AbstractListIterator()
| Method Detail |
|---|
protected final void setCursor(int newCursor)
forwardTo(int).
newCursor - new value of the underlying cursorprotected void forwardTo(int index)
next() until cursor equals specified index.
Used for starting at a specific position.
index - index of first element to be returned from the list
iterator (by a call to the next method).
IndexOutOfBoundsException - if
index < 0 || index > size().public abstract boolean hasNext()
hasNext in interface Iterator<E>hasNext in interface ListIterator<E>protected E get()
next() and previous().
Return the object at current cursor position.
public E next()
get() and increments the cursor.
next in interface Iterator<E>next in interface ListIterator<E>NoSuchElementException - if the iteration has no next element.public boolean hasPrevious()
cursor is zero.
hasPrevious in interface ListIterator<E>true if the cursor is zero.public E previous()
get().
previous in interface ListIterator<E>NoSuchElementException - if the iteration has no previous
element.public int nextIndex()
cursor.
nextIndex in interface ListIterator<E>public int previousIndex()
cursor-1.
previousIndex in interface ListIterator<E>public void remove()
UnsupportedOperationException.
remove in interface Iterator<E>remove in interface ListIterator<E>public void set(E o)
UnsupportedOperationException.
set in interface ListIterator<E>public void add(E o)
UnsupportedOperationException.
add in interface ListIterator<E>
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||