Class LinkedList<E>

java.lang.Object
  extended by LinkedList<E>
All Implemented Interfaces:
java.lang.Iterable<E>, ListADT<E>

public class LinkedList<E>
extends java.lang.Object
implements ListADT<E>

An Iterable list that is implemented using a singly-linked chain of nodes with a header node and without a tail reference. The "header node" is a node without a data reference that will reference the first node with data once data has been added to list. The iterator returned is a LinkedListIterator constructed by passing the first node with data. CAUTION: the chain of nodes in this class can be changed without calling the add and remove methods in this class. So, the size() method must be implemented by counting nodes. This counting must occur each time the size method is called. DO NOT USE a numItems field. COMPLETE THIS CLASS AND HAND IN THIS FILE


Constructor Summary
LinkedList()
           
 
Method Summary
 Listnode<E> getHeaderNode()
          Returns a reference to the header node for this linked list.
 LinkedListIterator<E> iterator()
          Returns a reference to a LinkedListIterator for this list.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface ListADT
add, add, contains, get, isEmpty, remove, size
 

Constructor Detail

LinkedList

public LinkedList()
Method Detail

getHeaderNode

public Listnode<E> getHeaderNode()
Returns a reference to the header node for this linked list. The header node is the first node in the chain and it does not contain a data reference. It does contain a reference to the first node with data (next node in the chain). That node will exist and contain a data reference if any data has been added to the list. NOTE: Typically, a LinkedList would not provide direct access to the headerNode in this way to classes that use the linked list. We are providing direct access to support testing and to allow multiple nodes to be moved as a chain.

Returns:
a reference to the header node of this list. 0

iterator

public LinkedListIterator<E> iterator()
Returns a reference to a LinkedListIterator for this list.

Specified by:
iterator in interface java.lang.Iterable<E>