Package io.openml.gearbox.binarytree
Class AbstractPreOrderTraversalVisitor<T>
java.lang.Object
io.openml.gearbox.binarytree.AbstractPreOrderTraversalVisitor<T>
- Type Parameters:
T
- The type of value wrapped in theVisitable
object to be visited by this visitor. For example, if the visitable class isImmutableTreeNode
, then the type of value is the return type of itsImmutableTreeNode.getValue()
method
- All Implemented Interfaces:
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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract void
processNode
(TreeNode<T> node) An abstract method that defines the operation to be performed on each node during the traversal.void
visit
(ImmutableTreeNode<T> node) Visits anImmutableTreeNode
.void
visit
(MutableTreeNode<T> node) Visits aMutableTreeNode
.
-
Constructor Details
-
AbstractPreOrderTraversalVisitor
public AbstractPreOrderTraversalVisitor()
-
-
Method Details
-
processNode
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
Description copied from interface:Visitor
Visits anImmutableTreeNode
. -
visit
Description copied from interface:Visitor
Visits aMutableTreeNode
.
-