Class LinkedListIterator<T>

java.lang.Object
  extended by LinkedListIterator<T>
All Implemented Interfaces:
java.util.Iterator<T>

public class LinkedListIterator<T>
extends java.lang.Object
implements java.util.Iterator<T>

The iterator implementation for LinkedList. The constructor for this class requires that a reference to a Listnode with the first data item is passed in. If the Listnode reference used to create the LinkedListIterator is null, that implies there is no data in the LinkedList and this iterator should handle that case correctly. COMPLETE THIS CLASS AND HAND IN THIS FILE


Constructor Summary
LinkedListIterator(Listnode<T> head)
          Constructs a LinkedListIterator when given the first node in a chain of nodes that contains data.
 
Method Summary
 boolean hasNext()
          Returns true if their are no more data items to iterate through for this list.
 T next()
          Returns the next element in the iteration and then advances the iteration reference.
 void remove()
          The remove operation is not supported by this iterator
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LinkedListIterator

public LinkedListIterator(Listnode<T> head)
Constructs a LinkedListIterator when given the first node in a chain of nodes that contains data.

Parameters:
a - reference to a List node that is a "header node". The "header node" does not have a data reference.
Method Detail

next

public T next()
Returns the next element in the iteration and then advances the iteration reference.

Specified by:
next in interface java.util.Iterator<T>
Returns:
the next data item in the iteration that has not yet been returned
Throws:
java.util.NoSuchElementException - if the iteration has no more elements

hasNext

public boolean hasNext()
Returns true if their are no more data items to iterate through for this list.

Specified by:
hasNext in interface java.util.Iterator<T>
Returns:
true if their are any remaining data items to iterator through

remove

public void remove()
The remove operation is not supported by this iterator

Specified by:
remove in interface java.util.Iterator<T>
Throws:
java.lang.UnsupportedOperationException - if the remove operation is not supported by this iterator