Package io.openml.gearbox.binarytree
Class MutableTreeNode<T>
java.lang.Object
io.openml.gearbox.binarytree.MutableTreeNode<T>
- Type Parameters:
T
- The type of value stored in this tree node
MutableTreeNode
saves the memory footprint of TreeNode
and is suitable for the performance intensive
application. It also represents a concrete 'Element', i.e. Visitable
.
As a mutable implementation of a TreeNode. Its value and children can be modified after creation.
-
Method Summary
Modifier and TypeMethodDescriptionvoid
The entry point for the visitor to perform its operations on this object.static <T> TreeNode<T>
Creates a dummy node withnull
value,null
left subtree, andnull
right subtree.getLeft()
Returns the reference to the left child of this tree node.getRight()
Returns the reference to the right child of this tree node.getValue()
Returns the object stored in this tree node.void
Mutates the left child of this node with a specified left subtree.void
Mutates the right child of this node with a specified lrighteft subtree.void
Mutates the value this node with a specified new one.static <T> TreeNode<T>
value
(T value) Creates a newTreeNode
with the specified node value.Returns a same instance with a specified new left child.Returns a same instance with a specified new right child.
-
Method Details
-
emptyNode
Creates a dummy node withnull
value,null
left subtree, andnull
right subtree.This would be a useful method for implementing algorithm that makes use of some auxiliary
TreeNode
. -
value
Creates a newTreeNode
with the specified node value.The left and right subtrees of this node are default to
null
.- Type Parameters:
T
- The type of value store in the node- Parameters:
value
- The provided node value, can benull
- Returns:
- a new
TreeNode
instance - Throws:
NullPointerException
- if thevalue
isnull
-
setLeft
Mutates the left child of this node with a specified left subtree.- Parameters:
left
- The provided left subtree; can benull
-
setRight
Mutates the right child of this node with a specified lrighteft subtree.- Parameters:
right
- The provided right subtree; can benull
-
setValue
Mutates the value this node with a specified new one.- Parameters:
value
- The provided new value; can benull
-
accept
Description copied from interface:Visitable
The entry point for the visitor to perform its operations on this object. -
withLeft
Description copied from interface:TreeNode
Returns a same instance with a specified new left child. -
withRight
Description copied from interface:TreeNode
Returns a same instance with a specified new right child. -
getValue
Description copied from interface:TreeNode
Returns the object stored in this tree node. -
getLeft
Description copied from interface:TreeNode
Returns the reference to the left child of this tree node. -
getRight
Description copied from interface:TreeNode
Returns the reference to the right child of this tree node.
-