Constructor and Description |
---|
TreeNode(E element)
Creates a new TreeNode with the specified element.
|
Modifier and Type | Method and Description |
---|---|
int |
getBalance()
Returns this node's balance.
|
E |
getElement()
Returns this node's element.
|
TreeNode<E> |
getLeftChild()
Returns this node's leftmost child.
|
TreeNode<E> |
getParent()
Returns this node's parent node.
|
TreeNode<E> |
getRightSibling()
Returns this node's right sibling.
|
TreeNode<E> |
removeLeftChild()
Removes this node's left child.
|
TreeNode<E> |
removeRightSibling()
Removes this node's right sibling.
|
void |
setBalance(int balance)
Sets this node's balance.
|
E |
setElement(E element)
Sets this node's element.
|
void |
setLeftChild(Tree<E> tree)
Sets this node's left child to be the root node of the specified
Tree.
|
void |
setLeftChild(TreeNode<E> node)
Sets this node's left child.
|
void |
setRightSibling(Tree<E> tree)
Sets this node's right sibling to be the root node of the specified
Tree . |
void |
setRightSibling(TreeNode<E> node)
Sets this node's right sibling.
|
public TreeNode(E element)
element
- the element for the TreeNode.public void setBalance(int balance)
balance
- the new balance for this node.public int getBalance()
public E getElement()
public E setElement(E element)
element
- new element for this node.ElementTypeMismatchException
- if the type of element
does not match that of this node.public TreeNode<E> getParent()
Tree
.public TreeNode<E> getLeftChild()
public void setLeftChild(TreeNode<E> node)
node
- the new left child.java.lang.NullPointerException
- if node is null.ElementTypeMismatchException
- if node's element type does
not match that of this node.public void setLeftChild(Tree<E> tree)
tree
- the Tree
the root node of which is
to be this node's left child.java.lang.NullPointerException
- if tree or its root node is
null.ElementTypeMismatchException
- if tree's element type does
not match that of this node.public TreeNode<E> removeLeftChild()
public TreeNode<E> getRightSibling()
public void setRightSibling(TreeNode<E> node)
node
- the new right sibling.java.lang.NullPointerException
- if node is null.TreeException
- if this node is the root node.public void setRightSibling(Tree<E> tree)
Tree
.tree
- the Tree
the root node of which is
to become this node's right sibling.java.lang.NullPointerException
- if tree or its root node is
null.ElementTypeMismatchException
- if tree's element type does
not match that of this node.