Class AbstractPreOrderTraversalVisitor<T>

java.lang.Object
io.openml.gearbox.binarytree.AbstractPreOrderTraversalVisitor<T>
Type Parameters:
T - The type of value wrapped in the Visitable object to be visited by this visitor. For example, if the visitable class is ImmutableTreeNode, then the type of value is the return type of its ImmutableTreeNode.getValue() method
All Implemented Interfaces:
Visitor<T>

public abstract class AbstractPreOrderTraversalVisitor<T> extends Object implements Visitor<T>
An abstract Visitor that performs an iterative pre-order traversal (Root, Left, Right).

This class follows the "combined" visitor model where the traversal logic is bundled inside the visitor for convenience. It uses the Template Method pattern, requiring subclasses to implement the processNode(TreeNode) method to define the action taken on each node.

For a detailed discussion of the architectural trade-offs between this combined approach and the more flexible, separated approach, please see the Javadoc for AbstractInOrderTraversalVisitor.

  • Constructor Details

    • AbstractPreOrderTraversalVisitor

      public AbstractPreOrderTraversalVisitor()
  • Method Details

    • processNode

      protected abstract void processNode(TreeNode<T> node)
      An abstract method that defines the operation to be performed on each node during the traversal.

      This is the customizable step in the template method.

      Parameters:
      node - The node being processed
    • visit

      public void visit(ImmutableTreeNode<T> node)
      Description copied from interface: Visitor
      Specified by:
      visit in interface Visitor<T>
      Parameters:
      node - The ImmutableTreeNode to visit.
    • visit

      public void visit(MutableTreeNode<T> node)
      Description copied from interface: Visitor
      Visits a MutableTreeNode.
      Specified by:
      visit in interface Visitor<T>
      Parameters:
      node - The MutableTreeNode to visit.