brs
Class ANode<T>

java.lang.Object
  extended by brs.ANode<T>
Direct Known Subclasses:
DatNode, EmptyNode

abstract class ANode<T>
extends java.lang.Object

Represents the state of the owner binary tree structure. Union pattern


Constructor Summary
ANode()
           
 
Method Summary
(package private) abstract
<R,P> R
execute(BiTree<T> owner, IVisitor<T,R,P> algo, P... inp)
          Calls the appropriate visitor's method to execute the visiting algorithm.
(package private) abstract  BiTree<T> getLeftSubTree(BiTree<T> owner)
          Gets the left subtree of the owner tree.
(package private) abstract  BiTree<T> getRightSubTree(BiTree<T> owner)
          Gets the right subtree of the owner tree.
(package private) abstract  T getRootDat(BiTree<T> owner)
          Gets the root data of the owner tree if it exists.
(package private) abstract  void insertRoot(BiTree<T> owner, T dat)
          Inserts a root element to the owner tree.
(package private) abstract  T remRoot(BiTree<T> owner)
          Removes and returns the root element from the owner tree.
(package private) abstract  void setLeftSubTree(BiTree<T> owner, BiTree<T> biTree)
          Sets the left subtree of the owner tree to a given tree.
(package private) abstract  void setRightSubTree(BiTree<T> owner, BiTree<T> biTree)
          Sets the right subtree of the owner tree to a given tree.
(package private) abstract  void setRootDat(BiTree<T> owner, T dat)
          Sets the root element of the owner tree to a given data object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ANode

ANode()
Method Detail

getRootDat

abstract T getRootDat(BiTree<T> owner)
Gets the root data of the owner tree if it exists.

Parameters:
owner - the BiTree that holds this node.
Returns:
the data element of this node if it exists.
Throws:
NoSuchElementException - if the owner is empty.

setRootDat

abstract void setRootDat(BiTree<T> owner,
                         T dat)
Sets the root element of the owner tree to a given data object.

Parameters:
dat -
owner - the BiTree that holds this node.
Throws:
NoSuchElementException - if the owner is empty.

getLeftSubTree

abstract BiTree<T> getLeftSubTree(BiTree<T> owner)
Gets the left subtree of the owner tree.

Parameters:
owner - the BiTree that holds this node.
Returns:
the left subtree of this node if it exists.
Throws:
NoSuchElementException - if the owner is empty.

getRightSubTree

abstract BiTree<T> getRightSubTree(BiTree<T> owner)
Gets the right subtree of the owner tree.

Parameters:
owner - the BiTree that holds this node.
Returns:
the right subtree of this node if it exists.
Throws:
NoSuchElementException - if the owner is empty.

setLeftSubTree

abstract void setLeftSubTree(BiTree<T> owner,
                             BiTree<T> biTree)
Sets the left subtree of the owner tree to a given tree.

Parameters:
biTree - != null.
owner - the BiTree that holds this node.
Throws:
NoSuchElementException - if the owner is empty.

setRightSubTree

abstract void setRightSubTree(BiTree<T> owner,
                              BiTree<T> biTree)
Sets the right subtree of the owner tree to a given tree.

Parameters:
biTree - != null.
owner - the BiTree that holds this node.
Throws:
NoSuchElementException - if the owner is empty.

insertRoot

abstract void insertRoot(BiTree<T> owner,
                         T dat)
Inserts a root element to the owner tree. Allows the owner tree to change state from empty to non-empty.

Parameters:
dat -
owner - the BiTree that holds this node.
Throws:
IllegaStateException - if the owner is not empty.

remRoot

abstract T remRoot(BiTree<T> owner)
Removes and returns the root element from the owner tree. Allows the owner tree to change state from non-empty to empty.

Parameters:
dat -
owner - the BiTree that holds this node.
Throws:
IllegaStateException - if the owner has more than one element.

execute

abstract <R,P> R execute(BiTree<T> owner,
                         IVisitor<T,R,P> algo,
                         P... inp)
Calls the appropriate visitor's method to execute the visiting algorithm.

Parameters:
owner - the BiTree that holds this node.
algo - the visiting algorithm
inp - the vararg input the algorithm needs.
Returns:
the output for the algorithm.