All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class DataStructures.LinkedListItr

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

public class LinkedListItr
extends java.lang.Object
implements DataStructures.ListItr
Linked list implementation of the list iterator using a header node.

See Also:
LinkedList

Constructor Index

 o LinkedListItr(LinkedList)
Construct the list.
 o LinkedListItr(List)
Construct the list.

Method Index

 o advance()
Advance the current position to the next node in the list.
 o copy(LinkedList, LinkedList)
 o find(Object)
Set the current position to the first node containing an item.
 o first()
Set the current position to the first node in the list.
 o insert(Object)
Insert after the current position.
 o isInList()
Test if the current position references a valid list item.
 o main(String[])
 o print(LinkedList)
 o remove(Object)
Remove the first occurrence of an item.
 o removeNext()
Remove the item after the current position.
 o retrieve()
Return the item stored in the current position.
 o zeroth()
Set the current position to the header node.

Constructors

 o LinkedListItr
 public LinkedListItr(DataStructures.List anyList) throws java.lang.ClassCastException
Construct the list.

Parameters:
anyList - a LinkedList object to which this iterator is permanently bound. This constructor is provided for convenience. If anyList is not a LinkedList object, a ClassCastException will result.
 o LinkedListItr
 public LinkedListItr(DataStructures.LinkedList anyList)
Construct the list. As a result of the construction, the current position is the first item, unless the list is empty, in which case the current position is the zeroth item.

Parameters:
anyList - a LinkedList object to which this iterator is permanently bound.

Methods

 o insert
 public void insert(java.lang.Object x) throws Exceptions.ItemNotFound
Insert after the current position. current is set to the inserted node on success.

Parameters:
x - the item to insert.
Throws: ItemNotFound
if the current position is null.
 o find
 public boolean find(java.lang.Object x)
Set the current position to the first node containing an item. current is unchanged if x is not found.

Parameters:
x - the item to search for.
Returns:
true if the item is found, false otherwise.
 o remove
 public void remove(java.lang.Object x) throws Exceptions.ItemNotFound
Remove the first occurrence of an item. current is set to the first node on success; remains unchanged otherwise.

Parameters:
x - the item to remove.
Throws: ItemNotFound
if the item is not found.
 o removeNext
 public boolean removeNext()
Remove the item after the current position. current is unchanged.

Returns:
true if successful false otherwise.
 o isInList
 public boolean isInList()
Test if the current position references a valid list item.

Returns:
true if the current position is not null and is not referencing the header node.
 o retrieve
 public java.lang.Object retrieve()
Return the item stored in the current position.

Returns:
the stored item or null if the current position is not in the list.
 o zeroth
 public void zeroth()
Set the current position to the header node.

 o first
 public void first()
Set the current position to the first node in the list. This operation is valid for empty lists.

 o advance
 public void advance()
Advance the current position to the next node in the list. If the current position is null, then do nothing. No exceptions are thrown by this routine because in the most common use (inside a for loop), this would require the programmer to add an unnecessary try/catch block.

 o copy
 public static void copy(DataStructures.LinkedList lhs,
                         DataStructures.LinkedList rhs)
 o print
 public static void print(DataStructures.LinkedList theList)
 o main
 public static void main(java.lang.String args[])

All Packages  Class Hierarchy  This Package  Previous  Next  Index