public class DecisionTree<T,C>
extends java.lang.Object
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.
Modifier and Type | Class and Description |
---|---|
static interface |
DecisionTree.Controller<T,C>
Interface defined by the class user to control traversal.
|
Modifier and Type | Field and Description |
---|---|
protected DecisionTree.Controller<T,C> |
controller |
Constructor and Description |
---|
DecisionTree(DecisionTree.Controller<T,C> controller)
Construct a decision tree for a given item type and controller type.
|
Modifier and Type | Method and Description |
---|---|
void |
traverse(T o,
C context)
Start tree traversal.
|
protected DecisionTree.Controller<T,C> controller
public DecisionTree(DecisionTree.Controller<T,C> controller)
controller
- a user-defined object implementing the Controller
interface providing the
traversal control methods.