Class binaryTree.DatNode
- class DatNode
- extends binaryTree.ANode
Stores data and represents a non-empty state.
- Author:
- Dung X. Nguyen - Copyright 1999 - All rights reserved.

_dat
- the stored data element
_leftTree
- Data Invariant: != null
_rightTree
- Data Invariant: != null

DatNode
(Object)
- Initialize the data element to a given object

execute
(IVisitor, Object, BiTree)
- Calls the visitor's nonNullCase () method to execute the visiting algorithm
getLeftSubTree
(BiTree)
- Gets the left subtree of the parent tree
getRightSubTree
(BiTree)
- Gets the right subtree of the parent tree
getRootDat
(BiTree)
- Gets the root data of the parent Tree
insertRoot
(Object, BiTree)
- Throws an IllegalStateException because the parent tree is not empty
remOurParent
(BiTree, BiTree)
- Throws an IllegalStateException because the parent tree is not empty
remParent
(BiTree, BiTree, BiTree)
- Throws an IllegalStateException because the parent tree is not empty
remRoot
(BiTree)
- Removes and returns the root element from the parent tree by handing the right
setLeftSubTree
(BiTree, BiTree)
- Sets the left subtree of this node to a given tree
setRightSubTree
(BiTree, BiTree)
- Sets the right subtree of this node to a given tree
setRootDat
(Object, BiTree)
- Sets the data element of this node to a given data object

_leftTree
private BiTree _leftTree
- Data Invariant: != null.
_dat
private Object _dat
- the stored data element.
_rightTree
private BiTree _rightTree
- Data Invariant: != null.

DatNode
DatNode(Object dat)
- Initialize the data element to a given object.
- Parameters:
- dat -

getRootDat
Object getRootDat(BiTree parent)
- Gets the root data of the parent Tree.
- Parameters:
- parent - the context of the state.
- Returns:
- the data element of this node.
setRootDat
void setRootDat(Object dat, BiTree parent)
- Sets the data element of this node to a given data object.
- Parameters:
- dat -
- parent - the context of this state.
getLeftSubTree
BiTree getLeftSubTree(BiTree parent)
- Gets the left subtree of the parent tree.
- Parameters:
- parent - the context of this state.
- Returns:
- the left subtree of this node.
getRightSubTree
BiTree getRightSubTree(BiTree parent)
- Gets the right subtree of the parent tree.
- Parameters:
- parent - the context of this state.
- Returns:
- the right subtree of this node.
setLeftSubTree
void setLeftSubTree(BiTree biTree, BiTree parent)
- Sets the left subtree of this node to a given tree.
Allows for growing the parent tree.
- Parameters:
- biTree - != null.
- parent - the context of this state.
setRightSubTree
void setRightSubTree(BiTree biTree, BiTree parent)
- Sets the right subtree of this node to a given tree.
Allows for growing the parent tree.
- Parameters:
- biTree - != null.
- parent - the context of this state.
insertRoot
void insertRoot(Object dat, BiTree parent)
- Throws an IllegalStateException because the parent tree is not empty.
- Throws: IllegaStateException.
remRoot
Object remRoot(BiTree parent)
- Removes and returns the root element from the parent tree by handing the right
subtree to the left subtree to do the job.
- Parameters:
- dat -
- parent - the context of this state.
- Throws: IllegaStateException
- if the parent has more than one element.
remParent
Object remParent(BiTree sis, BiTree grandPo, BiTree mom)
- Throws an IllegalStateException because the parent tree is not empty.
remOurParent
Object remOurParent(BiTree grandParent, BiTree parent)
- Throws an IllegalStateException because the parent tree is not empty.
execute
Object execute(IVisitor algo, Object input, BiTree parent)
- Calls the visitor's nonNullCase () method to execute the visiting algorithm.
- Parameters:
- algo - the visiting algorithm
- input - the input the algorithm needs.
- parent - the context of this node.
- Returns:
- the output for the nonNullCase() of the algorithm.