Class DecisionTree<T,​C>


  • public class DecisionTree<T,​C>
    extends java.lang.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

      Nested Classes 
      Modifier and Type Class Description
      static interface  DecisionTree.Controller<T,​C>
      Interface defined by the class user to control traversal.
    • Constructor Summary

      Constructors 
      Constructor Description
      DecisionTree​(DecisionTree.Controller<T,​C> controller)
      Construct a decision tree for a given item type and controller type.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void traverse​(T o, C context)
      Start tree traversal.
      • Methods inherited from class java.lang.Object

        clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • 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.