structure
Class DoublyLinkedListIterator

java.lang.Object
  extended by structure.AbstractIterator
      extended by structure.DoublyLinkedListIterator
All Implemented Interfaces:
java.util.Enumeration, java.util.Iterator

public class DoublyLinkedListIterator
extends AbstractIterator

A private iterator for traversing a doubly linked list.


Field Summary
protected  DoublyLinkedNode current
          Reference to the current node in the list.
protected  DoublyLinkedNode head
          Reference to head of the list.
protected  DoublyLinkedNode tail
          Sign of the end of the list.
 
Constructor Summary
DoublyLinkedListIterator(DoublyLinkedNode h)
          Construct an iterator over a doubly linked list hanging from head.
DoublyLinkedListIterator(DoublyLinkedNode headDummy, DoublyLinkedNode 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

head

protected DoublyLinkedNode head
Reference to head of the list.


tail

protected DoublyLinkedNode tail
Sign of the end of the list.


current

protected DoublyLinkedNode current
Reference to the current node in the list.

Constructor Detail

DoublyLinkedListIterator

public DoublyLinkedListIterator(DoublyLinkedNode h)
Construct an iterator over a doubly linked list hanging from head.

Parameters:
h - The head of the list to be traversed.
Postcondition:
constructs an iterator rooted at list head, h

DoublyLinkedListIterator

public DoublyLinkedListIterator(DoublyLinkedNode headDummy,
                                DoublyLinkedNode tailDummy)
Method Detail

reset

public void reset()
Reset the iterator to the head of the list.

Specified by:
reset in class AbstractIterator
Postcondition:
resets iterator to list head

hasNext

public boolean hasNext()
Determine if there are more elements to be considered.

Specified by:
hasNext in interface java.util.Iterator
Specified by:
hasNext in class AbstractIterator
Returns:
True iff there are more elements to be considered.
See Also:
AbstractIterator.hasMoreElements()
Postcondition:
returns true iff current element is valid

next

public java.lang.Object next()
Returns reference to the current element, then increments iterator.

Specified by:
next in interface java.util.Iterator
Specified by:
next in class AbstractIterator
Returns:
Reference to element that was current before increment.
See Also:
AbstractIterator.hasMoreElements(), AbstractIterator.value()
Postcondition:
returns current element and increments iterator

get

public java.lang.Object get()
Get reference to value that is current.

Specified by:
get in class AbstractIterator
Returns:
A reference to the value that is current.
Precondition:
hasNext
Postcondition:
returns current element