DataStructures
Class CursorList

java.lang.Object
  |
  +--DataStructures.CursorList

public class CursorList
extends java.lang.Object

Linked list implementation of the list using a header node; cursor version. Access to the list is via CursorListItr.

See Also:
CursorListItr

Constructor Summary
CursorList()
          Construct the list.
 
Method Summary
 CursorListItr find(java.lang.Object x)
          Return iterator corresponding to the first node containing an item.
 CursorListItr findPrevious(java.lang.Object x)
          Return iterator prior to the first node containing an item.
 CursorListItr first()
          Return an iterator representing the first node in the list.
 void insert(java.lang.Object x, CursorListItr p)
          Insert after p.
 boolean isEmpty()
          Test if the list is logically empty.
static void main(java.lang.String[] args)
           
 void makeEmpty()
          Make the list logically empty.
static void printList(CursorList theList)
           
 void remove(java.lang.Object x)
          Remove the first occurrence of an item.
 CursorListItr 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

CursorList

public CursorList()
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 CursorListItr zeroth()
Return an iterator representing the header node.

first

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

insert

public void insert(java.lang.Object x,
                   CursorListItr p)
Insert after p.
Parameters:
x - the item to insert.
p - the position prior to the newly inserted item.

find

public CursorListItr find(java.lang.Object x)
Return iterator corresponding to the first node containing an item.
Parameters:
x - the item to search for.
Returns:
an iterator; iterator isPastEnd if item is not found.

findPrevious

public CursorListItr findPrevious(java.lang.Object 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(java.lang.Object x)
Remove the first occurrence of an item.
Parameters:
x - the item to remove.

printList

public static void printList(CursorList theList)

main

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