|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Object
|
+--structure.AbstractIterator
|
+--structure.DoublyLinkedListIterator
An iterator for traversing the elements of a doubly linked list. The iterator traverses the list beginning at the head, and heads toward tail. Typical use:
List l = new DoublyLinkedList();
// ...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 DoublyLinkedListElement |
current
Reference to the current node in the list. |
protected DoublyLinkedListElement |
head
Reference to head of the list. |
protected DoublyLinkedListElement |
tail
Sign of the end of the list. |
| Constructor Summary | |
DoublyLinkedListIterator(DoublyLinkedListElement h)
Construct an iterator over a doubly linked list hanging from head. |
|
DoublyLinkedListIterator(DoublyLinkedListElement headDummy,
DoublyLinkedListElement tailDummy)
|
|
| Method Summary | |
java.lang.Object |
get()
Get reference to value that is current. |
boolean |
hasNext()
Determine if there are more elements to be considered. |
java.lang.Object |
next()
Returns reference to the current element, then increments iterator. |
void |
reset()
Reset the iterator to 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 DoublyLinkedListElement head
protected DoublyLinkedListElement tail
protected DoublyLinkedListElement current
| Constructor Detail |
public DoublyLinkedListIterator(DoublyLinkedListElement h)
h - The head of the list to be traversed.
public DoublyLinkedListIterator(DoublyLinkedListElement headDummy,
DoublyLinkedListElement tailDummy)
| Method Detail |
public void reset()
reset in class AbstractIteratorpublic boolean hasNext()
hasNext in interface java.util.IteratorhasNext in class AbstractIteratorAbstractIterator.hasMoreElements()public java.lang.Object next()
next in interface java.util.Iteratornext in class AbstractIteratorAbstractIterator.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 | ||||||||