Class AbstractVisitor<T,R>
java.lang.Object
io.openml.gearbox.binarytree.traversal.AbstractVisitor<T,R>
- Type Parameters:
T
- The type of value stored in the nodeR
- The type of object to be computed via a visiting the tree, seegetTraversalResult()
- Direct Known Subclasses:
AbstractInOrderVisitor
,AbstractPostOrderVisitor
,AbstractPreOrderVisitor
@Deprecated
public abstract class AbstractVisitor<T,R>
extends Object
implements Function<TreeNode<T>,R>
Deprecated.
AbstractVisitor
represents the notion of iteratively reading a binary tree.
It offers 3 common operations that can be shared across implementations
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract boolean
Deprecated.Returns whether or not the traversal should terminate early and callgetTraversalResult()
right after.protected abstract R
Deprecated.Returns the final result computed after visiting tree (either all-node visit or partial visit)protected abstract void
Deprecated.Performs actions on each visited node during traversal.
-
Constructor Details
-
AbstractVisitor
public AbstractVisitor()Deprecated.
-
-
Method Details
-
getTraversalResult
Deprecated.Returns the final result computed after visiting tree (either all-node visit or partial visit)For example, this method can return the max node value of entire tree after iterating through all tree nodes.
- Returns:
- object computed by a complete or partial traversal
-
visitNode
Deprecated.Performs actions on each visited node during traversal.- Parameters:
node
- Node on which the action is performed against
-
canTerminate
protected abstract boolean canTerminate()Deprecated.Returns whether or not the traversal should terminate early and callgetTraversalResult()
right after.For example, this could be useful while searching a tree for a target
1 / \ 2 3 / \ \ 4 5 6
Suppose we are searching for node 2 in the tree above.canTerminate()
can be implemented asif (node.value == 2) { return true } else { return false }
- Returns:
true
if traversal result is already publishable.
-
AbstractInOrderVisitor
reflects an obsolete implementation that doesn't strictly bind the principle of Visitor pattern. Please use the enhancedTreeTraverser