All Packages Class Hierarchy This Package Previous Next Index
Interface DataStructures.ListItr
- public interface ListItr
Protocol for list iterators
using a header node.
- See Also:
- List
-
advance()
- Advance the current position to the next node in the list.
-
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.
-
remove(Object)
- Remove the first occurrence of an item.
-
retrieve()
- Return the item stored in the current position.
-
zeroth()
- Set the current position to the header node.
insert
public abstract void insert(Object x) throws 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 abstract boolean find(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 abstract void remove(Object x) throws 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.
isInList
public abstract 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 abstract 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 abstract void zeroth()
- Set the current position to the header node.
first
public abstract void first()
- Set the current position to the first node in the list.
This operation is valid for empty lists.
advance
public abstract 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.
All Packages Class Hierarchy This Package Previous Next Index