All Packages Class Hierarchy This Package Previous Next Index
Class jdsl.core.ref.InOrderIterator
java.lang.Object
|
+----jdsl.core.ref.InOrderIterator
- public class InOrderIterator
- extends Object
The inorder iterator tells what, for an inorder traversal
of the tree, the first, last, next, prev elements are,
and can output a whole traversal of the tree, including
the leaves.
- Version:
- $Revision: 1.2 $, $Date: 1998/06/30 20:00:32 $
- Author:
- Ryan Shaun Baker, Mike Boilen (mgb)
-
InOrderIterator(InspectableBinaryTree)
-
Constructs a new InOrderIterator to iterate the given container
-
current()
-
Gets the current
Position
-
first()
-
The first position in the in-order traversal
-
last()
-
The last position in the in-order traversal
-
next()
- Gets the next
Position
-
prev()
-
Returns the in-order-previous of the given locator, including the leafs
Throws a BoundaryViolationException if c is the first node in inorder
traversal
-
setCurrent(Position)
- Sets the Iterator's current Locator to newCurrent.
-
traversal()
-
Generates the inorder traversal of the tree.
InOrderIterator
public InOrderIterator(InspectableBinaryTree tree)
- Constructs a new InOrderIterator to iterate the given container
current
public Position current()
- Gets the current
Position
- Returns:
- the current Position.
setCurrent
public void setCurrent(Position newCurrent)
- Sets the Iterator's current Locator to newCurrent.
- Parameters:
- newCurrent - the Iterator's new current Locator
next
public Position next() throws BoundaryViolationException
- Gets the next
Position
- Throws: BoundaryViolationException
- If the iterator is at the last
Position.
prev
public Position prev() throws BoundaryViolationException
- Returns the in-order-previous of the given locator, including the leafs
Throws a BoundaryViolationException if c is the first node in inorder
traversal
- Returns:
- the in-order-previous of the given locator, including the leaves
- Throws: BoundaryViolationException
- if called when at the beginning of
the tree.
first
public Position first()
- The first position in the in-order traversal
- Returns:
- a locator to the in-order-first element of the tree, which is a leaf
goes from left child to left child until reaching a leaf.
last
public Position last()
- The last position in the in-order traversal
- Returns:
- a locator to the in-order-last element of the tree, which is a leaf
goes from right child to right child until reaching a leaf.
traversal
public Sequence traversal()
- Generates the inorder traversal of the tree.
- Returns:
- the inorder sequence of locators to the internal AND leaf nodes of
the tree
All Packages Class Hierarchy This Package Previous Next Index