Class binaryTree.ANode


abstract class ANode
extends Object
Represents the state of the owner binary tree structure. Union pattern

Author:
Dung X. Nguyen - Copyright 1999 - All rights reserved.

Method Index

 o execute (IVisitor, Object, BiTree)
Calls the appropriate visitor's method to execute the visiting algorithm
 o getLeftSubTree (BiTree)
Gets the left subtree of the owner tree
 o getRightSubTree (BiTree)
Gets the right subtree of the owner tree
 o getRootDat (BiTree)
Gets the root data of the owner tree if it exists
 o insertRoot (Object, BiTree)
Inserts a root element to the owner tree
 o remParent (BiTree, BiTree, BiTree)
Removes and return the root element of the parent of the owner of this node,
 o remParentNode (BiTree, BiTree)
Removes and return the root element of the parent of the owner of this node,
 o remRoot (BiTree)
Removes and returns the root element from the owner tree
 o setLeftSubTree (BiTree, BiTree)
Sets the left subtree of the owner tree to a given tree
 o setRightSubTree (BiTree, BiTree)
Sets the right subtree of the owner tree to a given tree
 o setRootDat (Object, BiTree)
Sets the root element of the owner tree to a given data object

Methods

 o getRootDat
abstract Object getRootDat(BiTree owner)
Gets the root data of the owner tree if it exists.

Parameters:
owner - the context of the state.
Returns:
the data element of this node if it exists.
Throws: NoSuchElementException
if the owner is empty.
 o setRootDat
abstract void setRootDat(Object dat, BiTree owner)
Sets the root element of the owner tree to a given data object.

Parameters:
dat -
owner - the context of this state.
Throws: NoSuchElementException
if the owner is empty.
 o getLeftSubTree
abstract BiTree getLeftSubTree(BiTree owner)
Gets the left subtree of the owner tree.

Parameters:
owner - the context of this state.
Returns:
the left subtree of this node if it exists.
Throws: NoSuchElementException
if the owner is empty.
 o getRightSubTree
abstract BiTree getRightSubTree(BiTree owner)
Gets the right subtree of the owner tree.

Parameters:
owner - the context of this state.
Returns:
the right subtree of this node if it exists.
Throws: NoSuchElementException
if the owner is empty.
 o setLeftSubTree
abstract void setLeftSubTree(BiTree biTree, BiTree owner)
Sets the left subtree of the owner tree to a given tree. Allows for growing the owner tree.

Parameters:
biTree - != null.
owner - the context of this state.
Throws: NoSuchElementException
if the owner is empty.
 o setRightSubTree
abstract void setRightSubTree(BiTree biTree, BiTree owner)
Sets the right subtree of the owner tree to a given tree. Allows for growing the owner tree.

Parameters:
biTree - != null.
owner - the context of this state.
Throws: NoSuchElementException
if the owner is empty.
 o insertRoot
abstract void insertRoot(Object dat, BiTree owner)
Inserts a root element to the owner tree. Allows for state change from empty to non-empty.

Parameters:
dat -
owner - the context of this state.
Throws: IllegaStateException
if the owner is not empty.
 o remRoot
abstract Object remRoot(BiTree owner)
Removes and returns the root element from the owner tree. Allows for state change from non-empty to empty.

Parameters:
dat -
owner - the context of this state.
Throws: IllegaStateException
if the owner has more than one element.
 o remParent
abstract Object remParent(BiTree oSib, BiTree oDad, BiTree owner)
Removes and return the root element of the parent of the owner of this node, asking the sibbling of the owner tree to do it if necessary.

Parameters:
oSib - the sibbling of the owner of this node.
oDad - the parent of the owner of this node.
owner - the context of this node.
Returns:
the root data of the parent of the owner of this ANode.
 o remParentNode
abstract Object remParentNode(BiTree ownerDad, BiTree owner)
Removes and return the root element of the parent of the owner of this node, knowing that the sibbling of the owner tree is empty.

Parameters:
ownerDad - the parent of the owner of this ANode.
owner - the context of this node.
Returns:
the root data of the parent of the owner of this ANode.
 o execute
abstract Object execute(IVisitor algo, Object input, BiTree owner)
Calls the appropriate visitor's method to execute the visiting algorithm.

Parameters:
algo - the visiting algorithm
input - the input the algorithm needs.
owner - the context of this node.
Returns:
the output for the algorithm.