Class List


			
template class List<class Type>
Programmer: Ryan Davis

Description:

Define a "plug & play" linked list class that provides all mechanisms needed to store random homogonous data. the list is doubly linked and can be walked backwards or forwards. It can also find, remove, etc...

Public Methods:

List ();
Creates a new list with no nodes (except exemplars).

virtual ~List ();
Deletes all nodes in the list.

virtual Boolean isEmpty ();
Returns true if list has more than zero nodes.

virtual Boolean append (const Type & item);
Adds new node containing item to end of list. Returns true if successful.

virtual Boolean prepend (const Type & item);
Adds a new node containing item to the begining of the list. Returns true if successful.

virtual Boolean remove ();
Removes the node referenced by current(). If current is null, does nothing, otherwise returns true and calls reset.

virtual Boolean find (const Type & item);
Locates first node containing item in list. Returns true if item is found and points current to that node. If not successful, returns false and doesn't change the previous value of current.

virtual UInteger size ();
Returns the number of nodes (- exemplars) in list.

virtual void reset ();
Sets current to NULL, for use with walkForward() & walkBackward()

virtual Boolean atEnd ();
Returns true if current is at the last node in the list or number of nodes in list is zero. Returns false otherwise.

virtual Boolean atHead ();
Returns true if current is at the first node in the list or number of nodes in list is zero. Returns false otherwise.

virtual Type & value ();
Returns a reference to the value referenced by current. Conditions: will bomb if no items in list. Proper usage should test isEmpty().

virtual Boolean walkForward ();
eqv. of postfix operator ++ Returns false if current = tail or if the list contains no nodes Otherwise, if current == NULL then sets current to head :. returns true ..Otherwise sets current to current's next :. returns true

virtual Boolean walkBackward ();
eqv. of postfix operator -- Returns false if current = head or if the list contains no nodes Otherwise, if current == NULL then sets current to tail :. returns true ..Otherwise sets current to current's prev :. returns true Data

Protected Methods:

void head (ListNode<Type> * newHead);


ListNode<Type> * head ();


void tail (ListNode<Type> * newTail);


ListNode<Type> * tail ();


void current (ListNode<Type> * newCurrent);


ListNode<Type> * current ();


Protected Members: