All Packages Class Hierarchy This Package Previous Next Index
Class DataStructures.TreeIterator
java.lang.Object
|
+----DataStructures.TreeIterator
- public abstract class TreeIterator
- extends Object
Tree iterator class.
-
current
- Current position.
-
t
- The tree.
-
TreeIterator(BinarySearchTree)
- Construct the iterator.
-
advance()
- Advance the current position to the next node in the tree,
according to the traversal scheme.
-
first()
- Set the current position to the first item, according
to the traversal scheme.
-
isValid()
- Test if current position references a valid tree item.
-
main(String[])
-
-
retrieve()
- Return the item stored in the current position.
-
testItr(String, TreeIterator)
-
t
protected BinarySearchTree t
- The tree.
current
protected BinaryNode current
- Current position.
TreeIterator
public TreeIterator(BinarySearchTree theTree)
- Construct the iterator.
The current position is set to null.
- Parameters:
- theTree - the tree to which the iterator is
permanently bound.
first
public abstract void first()
- Set the current position to the first item, according
to the traversal scheme.
isValid
public final boolean isValid()
- Test if current position references a valid tree item.
- Returns:
- true if the current position is not null; false otherwise.
retrieve
public final Object retrieve() throws ItemNotFound
- Return the item stored in the current position.
- Returns:
- the stored item.
- Throws:
ItemNotFound
- if the current position is invalid.
advance
public abstract void advance() throws ItemNotFound
- Advance the current position to the next node in the tree,
according to the traversal scheme.
If the current position is null, then throw an exception.
This is the alternate strategy, that we did not use for lists.
- Throws:
ItemNotFound
- if the current position is null.
main
public static void main(String[] args)
testItr
public static void testItr(String type,
TreeIterator itr)
All Packages Class Hierarchy This Package Previous Next Index