All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class DataStructures.TreeIterator

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

public class TreeIterator
extends Object
Tree iterator class.


Variable Index

 o current
Current position.
 o t
The tree.

Constructor Index

 o TreeIterator(BinarySearchTree)
Construct the iterator.

Method Index

 o advance()
Advance the current position to the next node in the tree, according to the traversal scheme.
 o first()
Set the current position to the first item, according to the traversal scheme.
 o isValid()
Test if current position references a valid tree item.
 o main(String[])
 o retrieve()
Return the item stored in the current position.
 o testItr(String, TreeIterator)

Variables

 o t
  protected BinarySearchTree t
The tree.

 o current
  protected BinaryNode current
Current position.

Constructors

 o 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.

Methods

 o first
  public abstract void first()
Set the current position to the first item, according to the traversal scheme.

 o 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.
 o 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.
 o 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.
 o main
  public static void main(String args[])
 o testItr
  public static void testItr(String type,
                             TreeIterator itr)

All Packages  Class Hierarchy  This Package  Previous  Next  Index