Algorithm
Development Kit 1.0

algs.model.kdtree
Class KDTraversal

java.lang.Object
  extended by algs.model.kdtree.KDTraversal
All Implemented Interfaces:
IVisitKDNode

public abstract class KDTraversal
extends java.lang.Object
implements IVisitKDNode

Defines a standard inorder traversal of the KDTree and enables subclasses to provide specialized method to take action at each node of the tree.

By referencing the tree, the traversal can be reused even when the tree is altered. Note, however, that altering the tree structure during a traversal will lead to non-determined behavior.

This traversal supports both traversals starting at the root, and those starting at arbitrary points in the hierarchy of the tree.

Since:
1.0
Version:
1.0, 6/15/08
Author:
George Heineman

Constructor Summary
protected KDTraversal()
          Default constructor to properly enable subclasses to work.
  KDTraversal(KDTree tree)
          Start traversal at the root.
  KDTraversal(KDTree tree, DimensionalNode node)
          Start traversal at the given node within the tree rooted at tree
 
Method Summary
 void drain(DimensionalNode node)
          During a regular traversal, drain is not invoked.
 void traverse()
          Control the traversal of the entire Tree.
abstract  void visit(DimensionalNode node)
          Specialized behavior will be placed here.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

KDTraversal

protected KDTraversal()
Default constructor to properly enable subclasses to work.


KDTraversal

public KDTraversal(KDTree tree)
Start traversal at the root.

Parameters:
tree - need the tree over which traversal executes.

KDTraversal

public KDTraversal(KDTree tree,
                   DimensionalNode node)
Start traversal at the given node within the tree rooted at tree

Parameters:
tree - need the tree over which traversal executes.
node - node within tree at which to begin the traversal.
Method Detail

visit

public abstract void visit(DimensionalNode node)
Specialized behavior will be placed here.

Specified by:
visit in interface IVisitKDNode
Parameters:
node -

drain

public final void drain(DimensionalNode node)
During a regular traversal, drain is not invoked. To avoid subclasses mistakenly thinking they must provide this method, we implement here and mark as final to prevent that mistake. Since it is never called, this does nothing.

Specified by:
drain in interface IVisitKDNode

traverse

public void traverse()
Control the traversal of the entire Tree. Will visit each node in the tree starting from the cursor.


Algorithm Development Kit 1.0

This code supports the Algorithms in a Nutshell book, published by O'Reilly Media, Inc. in November 2008. Please visit the book web page to learn of any changes to the code repository or to record a potential defect.