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
- Current position.
 t t
- The tree.
 
 TreeIterator(BinarySearchTree) TreeIterator(BinarySearchTree)
- Construct the iterator.
 
 advance() advance()
- Advance the current position to the next node in the tree,
according to the traversal scheme.
 first() first()
- Set the current position to the first item, according
to the traversal scheme.
 isValid() isValid()
- Test if current position references a valid tree item.
 main(String[]) main(String[])
- 
 retrieve() retrieve()
- Return the item stored in the current position.
 testItr(String, TreeIterator) testItr(String, TreeIterator)
- 
 
 t
t
protected BinarySearchTree t
- The tree.
 
 current
current
protected BinaryNode current
- Current position.
 
 
 TreeIterator
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
first
public abstract void first()
- Set the current position to the first item, according
to the traversal scheme.
 
 isValid
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
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
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
main
public static void main(String[] args)
 testItr
testItr
public static void testItr(String type,
                           TreeIterator itr)
All Packages  Class Hierarchy  This Package  Previous  Next  Index