brs
Class EmptyNode<T>

java.lang.Object
  extended by brs.ANode<T>
      extended by brs.EmptyNode<T>

 class EmptyNode<T>
extends ANode<T>

Represents the empty state of a BiTree. Uses the singleton pattern to model the uniqueness of "emptiness".

Since:
03/11/02

Constructor Summary
EmptyNode()
           
 
Method Summary
(package private)
<R,P> R
execute(BiTree<T> owner, IVisitor<T,R,P> algo, P... inp)
          Calls algo's emptyCase () method to execute the algorithm algo.
(package private)  BiTree<T> getLeftSubTree(BiTree<T> owner)
          Throws java.util.NoSuchElementException.
(package private)  BiTree<T> getRightSubTree(BiTree<T> owner)
          Throws java.util.NoSuchElementException.
(package private)  T getRootDat(BiTree<T> owner)
          Throws java.util.NoSuchElementException.
(package private)  void insertRoot(BiTree<T> owner, T dat)
          Asks the owner tree to set the root node to a new DatNode containing dat, resulting in a state change from empty to non-empty.
(package private)  T remRoot(BiTree<T> owner)
          Throws java.util.NoSuchElementException.
(package private)  void setLeftSubTree(BiTree<T> owner, BiTree<T> biTree)
          Throws java.util.NoSuchElementException.
(package private)  void setRightSubTree(BiTree<T> owner, BiTree<T> biTree)
          Throws java.util.NoSuchElementException.
(package private)  void setRootDat(BiTree<T> owner, T dat)
          Throws java.util.NoSuchElementException.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

EmptyNode

EmptyNode()
Method Detail

getRootDat

T getRootDat(BiTree<T> owner)
Throws java.util.NoSuchElementException.

Specified by:
getRootDat in class ANode<T>
Parameters:
owner - the BiTree holding this EmptyNode.
Returns:
the data element of this node if it exists.

setRootDat

void setRootDat(BiTree<T> owner,
                T dat)
Throws java.util.NoSuchElementException.

Specified by:
setRootDat in class ANode<T>
Parameters:
dat - a data Object.
owner - the BiTree holding this EmptyNode.

getLeftSubTree

BiTree<T> getLeftSubTree(BiTree<T> owner)
Throws java.util.NoSuchElementException.

Specified by:
getLeftSubTree in class ANode<T>
Parameters:
owner - the BiTree holding this EmptyNode.
Returns:
the left subtree of this node if it exists.

getRightSubTree

BiTree<T> getRightSubTree(BiTree<T> owner)
Throws java.util.NoSuchElementException.

Specified by:
getRightSubTree in class ANode<T>
Parameters:
owner - the BiTree holding this EmptyNode.
Returns:
the right subtree of this node if it exists.

setLeftSubTree

void setLeftSubTree(BiTree<T> owner,
                    BiTree<T> biTree)
Throws java.util.NoSuchElementException.

Specified by:
setLeftSubTree in class ANode<T>
Parameters:
biTree - a given BiTree.
owner - the BiTree holding this EmptyNode.

setRightSubTree

void setRightSubTree(BiTree<T> owner,
                     BiTree<T> biTree)
Throws java.util.NoSuchElementException.

Specified by:
setRightSubTree in class ANode<T>
Parameters:
biTree - a given BiTree.
owner - the BiTree holding this EmptyNode.

insertRoot

void insertRoot(BiTree<T> owner,
                T dat)
Asks the owner tree to set the root node to a new DatNode containing dat, resulting in a state change from empty to non-empty.

Specified by:
insertRoot in class ANode<T>
Parameters:
dat - a given data Object.
owner - the context of this state.

remRoot

T remRoot(BiTree<T> owner)
Throws java.util.NoSuchElementException.

Specified by:
remRoot in class ANode<T>
Parameters:
owner - the BiTree holding this EmptyNode.

execute

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

Specified by:
execute in class ANode<T>
Parameters:
owner - the BiTree holding this EmptyNode.
algo - the visiting algorithm
inp - the vararg input algo needs.
Returns:
the output for the emptyCase() of algo.