|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--structure.AbstractIterator | +--structure.CircularListIterator
An iterator for traversing the elements of a circular list. The iterator traverses the list beginning at the head, and heads toward tail.
Typical use:
List l = new CircularList(); // ...list gets built up... Iterator li = l.iterator(); while (li.hasNext()) { System.out.println(li.get()); li.next(); } li.reset(); while (li.hasNext()) { .... }
Field Summary | |
protected SinglyLinkedListElement |
current
The current value of the iterator. |
protected SinglyLinkedListElement |
tail
The tail of the traversed list. |
Constructor Summary | |
CircularListIterator(SinglyLinkedListElement t)
Constructs an iterator over circular list whose tail is t |
Method Summary | |
java.lang.Object |
get()
Determine the current value of iterator. |
boolean |
hasNext()
Determine if there are unconsidered elements. |
java.lang.Object |
next()
Return the current value and increment iterator. |
void |
reset()
Resets iterator to consider the head of the list. |
Methods inherited from class structure.AbstractIterator |
hasMoreElements, nextElement, remove, value |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected SinglyLinkedListElement tail
protected SinglyLinkedListElement current
Constructor Detail |
public CircularListIterator(SinglyLinkedListElement t)
t
- The tail of the list to be traversed.Method Detail |
public void reset()
reset
in class AbstractIterator
public boolean hasNext()
hasNext
in interface java.util.Iterator
hasNext
in class AbstractIterator
AbstractIterator.hasMoreElements()
public java.lang.Object next()
next
in interface java.util.Iterator
next
in class AbstractIterator
AbstractIterator.hasMoreElements()
,
AbstractIterator.value()
public java.lang.Object get()
get
in class AbstractIterator
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |