NASA World Wind

gov.nasa.worldwind.util
Class DecisionTree<T,C>

java.lang.Object
  extended by gov.nasa.worldwind.util.DecisionTree<T,C>

public class DecisionTree<T,C>
extends Object

Traverses an implicit tree and makes decisions at tree nodes visited in depth-first order.

Users provide an object at construction that implements the DecisionTree.Controller interface. This controller provides methods to determine node inclusion, to terminate traversal, and to create descendant nodes. It is carried to each node during traversal.

Users also provide a user-defined context object to carry state and other information to each node. The context can hold information to assist in decisions or to retains objects or information gathered during traversal.

At the start of traversal a user-defined object is specified as the object defining the decision. It's the object against which decisions are made at each node.

See the source code of SectorVisibilityTree for example usage.


Nested Class Summary
static interface DecisionTree.Controller<T,C>
          Interface defined by the class user to control traversal.
 
Field Summary
protected  DecisionTree.Controller<T,C> controller
           
 
Constructor Summary
DecisionTree(DecisionTree.Controller<T,C> controller)
          Construct a decision tree for a given item type and controller type.
 
Method Summary
 void traverse(T o, C context)
          Start tree traversal.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

controller

protected DecisionTree.Controller<T,C> controller
Constructor Detail

DecisionTree

public DecisionTree(DecisionTree.Controller<T,C> controller)
Construct a decision tree for a given item type and controller type.

Parameters:
controller - a user-defined object implementing the Controller interface providing the traversal control methods.
Method Detail

traverse

public void traverse(T o,
                     C context)
Start tree traversal. The tree is visited in depth-first order.

Parameters:
o - a user-defined object to examine at each tree node.
context - the traversal context.

NASA World Wind