All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class DataStructures.TreeIterator

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

public abstract class TreeIterator
extends java.lang.Object
Tree iterator class.


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)

Constructors

 o TreeIterator
 public TreeIterator(DataStructures.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 java.lang.Object retrieve() throws Exceptions.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 Exceptions.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(java.lang.String args[])
 o testItr
 public static void testItr(java.lang.String type,
                            DataStructures.TreeIterator itr)

All Packages  Class Hierarchy  This Package  Previous  Next  Index