Class brs.DatNode
- class DatNode
- extends brs.ANode
Stores data and represents a non-empty state.
- Author:
- Dung X. Nguyen - Copyright 2001 - 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
(BiTree, IVisitor, Object[])
- Calls algo's nonEmptyCase() method to execute the algorithm algo
getLeftSubTree
(BiTree)
- Gets the left subtree of the owner tree
getRightSubTree
(BiTree)
- Gets the right subtree of the owner tree
getRootDat
(BiTree)
- Gets the root data of the owner Tree
insertRoot
(Object, BiTree)
- Throws an IllegalStateException because the owner tree is not empty
remRoot
(final BiTree)
- Removes and returns the root element from the owner tree by asking the
setLeftSubTree
(BiTree, BiTree)
- Sets the left subtree of this Datnode 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 = new BiTree ()
- Data Invariant: != null.
_dat
private Object _dat
- the stored data element.
_rightTree
private BiTree _rightTree = new BiTree ()
- Data Invariant: != null.

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

getRootDat
Object getRootDat(BiTree owner)
- Gets the root data of the owner Tree.
- Parameters:
- owner - the BiTree holding this DatNode.
- Returns:
- the data element of this DatNode.
setRootDat
void setRootDat(Object dat, BiTree owner)
- Sets the data element of this node to a given data object.
- Parameters:
- dat - a given data object.
- owner - the BiTree holding this DatNode.
getLeftSubTree
BiTree getLeftSubTree(BiTree owner)
- Gets the left subtree of the owner tree.
- Parameters:
- owner - the BiTree holding this DatNode.
- Returns:
- the left subtree of this DatNode.
getRightSubTree
BiTree getRightSubTree(BiTree owner)
- Gets the right subtree of the owner tree.
- Parameters:
- owner - the BiTree holding this DatNode.
- Returns:
- the right subtree of this DatNode.
setLeftSubTree
void setLeftSubTree(BiTree biTree, BiTree owner)
- Sets the left subtree of this Datnode to a given tree.
Allows for growing the owner tree.
- Parameters:
- biTree - != null. Does not check for null!
- owner - the BiTree holding this DatNode.
setRightSubTree
void setRightSubTree(BiTree biTree, BiTree owner)
- Sets the right subtree of this node to a given tree.
Allows for growing the owner tree.
- Parameters:
- biTree - != null. Does not check for null!
- owner - the BiTree holding this DatNode.
insertRoot
void insertRoot(Object dat, BiTree owner)
- Throws an IllegalStateException because the owner tree is not empty.
- Throws: IllegaStateException.
remRoot
Object remRoot(final BiTree owner)
- Removes and returns the root element from the owner tree by asking the
left subtree and, if necessary, the right subtree to help do the job.
The subtrees help determine whether or not the root element can be removed
by executing appropriate anonymous visitors.
- Parameters:
- owner - the BiTree holding this DatNode. Why is it final?
- Throws: IllegaStateException
- if both subtrees of owner are non-empty.
execute
Object execute(BiTree owner, IVisitor algo, Object[] inp)
- Calls algo's nonEmptyCase() method to execute the algorithm algo.
- Parameters:
- algo - an algorithm on owner.
- inp - the input algo needs.
- owner - the BiTree holding this DatNode.
- Returns:
- the output for the nonEmptyCase() of algo.