weiss.nonstandard
Class LinkedList<AnyType>

java.lang.Object
  extended by weiss.nonstandard.LinkedList<AnyType>
Direct Known Subclasses:
SortedLinkedList

public class LinkedList<AnyType>
extends java.lang.Object

Linked list implementation of the list using a header node. Access to the list is via LinkedListIterator.

See Also:
LinkedListIterator

Constructor Summary
LinkedList()
          Construct the list
 
Method Summary
 LinkedListIterator<AnyType> find(AnyType x)
          Return iterator corresponding to the first node containing an item.
 LinkedListIterator<AnyType> findPrevious(AnyType x)
          Return iterator prior to the first node containing an item.
 LinkedListIterator<AnyType> first()
          Return an iterator representing the first node in the list.
 void insert(AnyType x, LinkedListIterator<AnyType> p)
          Insert after p.
 boolean isEmpty()
          Test if the list is logically empty.
static
<AnyType> int
listSize(LinkedList<AnyType> theList)
           
static void main(java.lang.String[] args)
           
 void makeEmpty()
          Make the list logically empty.
static
<AnyType> void
printList(LinkedList<AnyType> theList)
           
 void remove(AnyType x)
          Remove the first occurrence of an item.
 LinkedListIterator<AnyType> zeroth()
          Return an iterator representing the header node.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LinkedList

public LinkedList()
Construct the list

Method Detail

isEmpty

public boolean isEmpty()
Test if the list is logically empty.

Returns:
true if empty, false otherwise.

makeEmpty

public void makeEmpty()
Make the list logically empty.


zeroth

public LinkedListIterator<AnyType> zeroth()
Return an iterator representing the header node.


first

public LinkedListIterator<AnyType> first()
Return an iterator representing the first node in the list. This operation is valid for empty lists.


insert

public void insert(AnyType x,
                   LinkedListIterator<AnyType> p)
Insert after p.

Parameters:
x - the item to insert.
p - the position prior to the newly inserted item.

find

public LinkedListIterator<AnyType> find(AnyType x)
Return iterator corresponding to the first node containing an item.

Parameters:
x - the item to search for.
Returns:
an iterator; iterator is not valid if item is not found.

findPrevious

public LinkedListIterator<AnyType> findPrevious(AnyType x)
Return iterator prior to the first node containing an item.

Parameters:
x - the item to search for.
Returns:
appropriate iterator if the item is found. Otherwise, the iterator corresponding to the last element in the list is returned.

remove

public void remove(AnyType x)
Remove the first occurrence of an item.

Parameters:
x - the item to remove.

printList

public static <AnyType> void printList(LinkedList<AnyType> theList)

listSize

public static <AnyType> int listSize(LinkedList<AnyType> theList)

main

public static void main(java.lang.String[] args)