Class Size<T>
java.lang.Object
io.openml.gearbox.binarytree.traversal.AbstractVisitor<T,R>
io.openml.gearbox.binarytree.traversal.AbstractPreOrderVisitor<T,Long>
io.openml.gearbox.binarytree.traversal.Size<T>
- Type Parameters:
T
- The type of value store in the tree node
Deprecated.
Computes the size of a binary tree.
The size of a binary tree is defined to be the number of nodes it has.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected boolean
Deprecated.Returns whether or not the traversal should terminate early and callAbstractVisitor.getTraversalResult()
right after.protected Long
Deprecated.Returns the final result computed after visiting tree (either all-node visit or partial visit)static <T> Long
Deprecated.One-time computes the size of a specified binary tree.protected void
Deprecated.Performs actions on each visited node during traversal.Methods inherited from class io.openml.gearbox.binarytree.traversal.AbstractPreOrderVisitor
apply, traverse
-
Constructor Details
-
Size
public Size()Deprecated.
-
-
Method Details
-
of
Deprecated.One-time computes the size of a specified binary tree.- Type Parameters:
T
- The type of value store in the tree node- Parameters:
root
- The root of the specified binary tree- Returns:
- the number of nodes in the tree
- Throws:
NullPointerException
- ifroot
isnull
-
getTraversalResult
Deprecated.Description copied from class:AbstractVisitor
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.
- Specified by:
getTraversalResult
in classAbstractVisitor<T,
Long> - Returns:
- object computed by a complete or partial traversal
-
visitNode
Deprecated.Description copied from class:AbstractVisitor
Performs actions on each visited node during traversal.- Specified by:
visitNode
in classAbstractVisitor<T,
Long> - Parameters:
node
- Node on which the action is performed against
-
canTerminate
protected boolean canTerminate()Deprecated.Description copied from class:AbstractVisitor
Returns whether or not the traversal should terminate early and callAbstractVisitor.getTraversalResult()
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.AbstractVisitor.canTerminate()
can be implemented asif (node.value == 2) { return true } else { return false }
- Specified by:
canTerminate
in classAbstractVisitor<T,
Long> - Returns:
true
if traversal result is already publishable.
-
Size
reflects an obsolete implementation that doesn't strictly bind the principle of Visitor pattern. Please use the enhancedTreeTraverser