Class brs.EmptyNode


class EmptyNode
extends brs.ANode
Represents the empty state of a BiTree. Uses the singleton pattern to model the uniqueness of "emptiness".

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

Variable Index

 o Singleton

Constructor Index

 o EmptyNode ()

Method Index

 o execute (BiTree, IVisitor, Object[])
Calls algo's emptyCase () method to execute the algorithm algo
 o getLeftSubTree (BiTree)
Throws java
 o getRightSubTree (BiTree)
Throws java
 o getRootDat (BiTree)
Throws java
 o insertRoot (Object, BiTree)
Asks the owner tree to set the root node to a new DatNode containing dat,
 o remRoot (BiTree)
Throws java
 o setLeftSubTree (BiTree, BiTree)
Throws java
 o setRightSubTree (BiTree, BiTree)
Throws java
 o setRootDat (Object, BiTree)
Throws java

Variables

 o Singleton
static final EmptyNode Singleton = new EmptyNode ()

Constructors

 o EmptyNode
private  EmptyNode()

Methods

 o getRootDat
Object getRootDat(BiTree owner)
Throws java.util.NoSuchElementException.

Parameters:
owner - the BiTree holding this EmptyNode.
 o setRootDat
void setRootDat(Object dat, BiTree owner)
Throws java.util.NoSuchElementException.

Parameters:
dat - a data Object.
owner - the BiTree holding this EmptyNode.
 o getLeftSubTree
BiTree getLeftSubTree(BiTree owner)
Throws java.util.NoSuchElementException.

Parameters:
owner - the BiTree holding this EmptyNode.
 o getRightSubTree
BiTree getRightSubTree(BiTree owner)
Throws java.util.NoSuchElementException.

Parameters:
owner - the BiTree holding this EmptyNode.
 o setLeftSubTree
void setLeftSubTree(BiTree biTree, BiTree owner)
Throws java.util.NoSuchElementException.

Parameters:
biTree - a given BiTree.
owner - the BiTree holding this EmptyNode.
 o setRightSubTree
void setRightSubTree(BiTree biTree, BiTree owner)
Throws java.util.NoSuchElementException.

Parameters:
biTree - a given BiTree.
owner - the BiTree holding this EmptyNode.
 o insertRoot
void insertRoot(Object dat, BiTree owner)
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.

Parameters:
dat - a given data Object.
owner - the context of this state.
 o remRoot
Object remRoot(BiTree owner)
Throws java.util.NoSuchElementException.

Parameters:
owner - the BiTree holding this EmptyNode.
 o execute
Object execute(BiTree owner, IVisitor algo, Object[] inp)
Calls algo's emptyCase () method to execute the algorithm algo.

Parameters:
algo - the visiting algorithm
inp - the input algo needs.
owner - the BiTree holding this EmptyNode.
Returns:
the output for the emptyCase() of algo.