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
-
LinkedListItr(LinkedList)
- Construct the list.
-
LinkedListItr(List)
- Construct the list.
-
advance()
- Advance the current position to the next node in the list.
-
copy(LinkedList, LinkedList)
-
-
find(Object)
- Set the current position to the first node containing an item.
-
first()
- Set the current position to the first node in the list.
-
insert(Object)
- Insert after the current position.
-
isInList()
- Test if the current position references a valid list item.
-
main(String[])
-
-
print(LinkedList)
-
-
remove(Object)
- Remove the first occurrence of an item.
-
removeNext()
- Remove the item after the current position.
-
retrieve()
- Return the item stored in the current position.
-
zeroth()
- Set the current position to the header node.
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.
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.
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.
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.
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.
removeNext
public boolean removeNext()
- Remove the item after the current position.
current is unchanged.
- Returns:
- true if successful false otherwise.
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.
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.
zeroth
public void zeroth()
- Set the current position to the header node.
first
public void first()
- Set the current position to the first node in the list.
This operation is valid for empty lists.
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.
copy
public static void copy(DataStructures.LinkedList lhs,
DataStructures.LinkedList rhs)
print
public static void print(DataStructures.LinkedList theList)
main
public static void main(java.lang.String args[])
All Packages Class Hierarchy This Package Previous Next Index