Class MutableTreeNode<T>
java.lang.Object
io.openml.gearbox.algorithms.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 TypeMethodDescriptionvoidThe entry point for the visitor to perform its operations on this object.static <T> TreeNode<T> Creates a dummy node withnullvalue,nullleft subtree, andnullright 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.voidMutates the left child of this node with a specified left subtree.voidMutates the right child of this node with a specified lrighteft subtree.voidMutates the value this node with a specified new one.static <T> TreeNode<T> value(T value) Creates a newTreeNodewith the specified node value.static <T> TreeNode<T> valueWithLeft(T value, TreeNode<T> left) Creates a newTreeNodewith the specified node value and a left subtree.static <T> TreeNode<T> valueWithLeftAndRight(T value, TreeNode<T> left, TreeNode<T> right) Creates a newTreeNodewith the specified node value, a left subtree, and a right subtree.static <T> TreeNode<T> valueWithRight(T value, TreeNode<T> right) Creates a newTreeNodewith the specified node value and a right subtree.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 withnullvalue,nullleft subtree, andnullright subtree.This would be a useful method for implementing algorithm that makes use of some auxiliary
TreeNode. -
value
Creates a newTreeNodewith 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
TreeNodeinstance - Throws:
NullPointerException- if thevalueisnull
-
valueWithLeft
Creates a newTreeNodewith the specified node value and a left subtree.The right subtree of this node is default to
null- Type Parameters:
T- The type of value store in the node- Parameters:
value- The provided node valueleft- The provided left subtree- Returns:
- a new
TreeNodeinstance - Throws:
NullPointerException- if thevalueorleftisnull
-
valueWithRight
Creates a newTreeNodewith the specified node value and a right subtree.The left subtree of this node is default to
null- Type Parameters:
T- The type of value store in the node- Parameters:
value- The provided node valueright- The provided right subtree- Returns:
- a new
TreeNodeinstance - Throws:
NullPointerException- if thevalueorrightisnull
-
valueWithLeftAndRight
Creates a newTreeNodewith the specified node value, a left subtree, and a right subtree. -
setLeft
-
setRight
-
setValue
Mutates the value this node with a specified new one.- Parameters:
value- The provided new value; can benull
-
accept
-
withLeft
-
withRight
-
getValue
-
getLeft
-
getRight
-