All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class jdsltools.testers.binarytreetester.BinaryTreeFactory

java.lang.Object
   |
   +----jdsltools.testers.GenericFactory
           |
           +----jdsltools.testers.binarytreetester.BinaryTreeFactory

public class BinaryTreeFactory
extends GenericFactory
Builds BinaryTree's.
Key followed by Meaning
MT_TREE: Produces an empty tree which has only one external node.
SAPLING: Produces a tree with three nodes, one internal and two external
RANDOM: Produces a tree of random shape. Pass in the number of external nodes the tree is to have instead of a location. All of the positions will be returned. Uses expandExternal, isExternal, leftChild, and rightChild
ROOT: represents the Position at the root.
THREE: represents the three positions made in SAPLING
NON_ROOT: represents a non root position.

Uses root(), positions(), and newContainer()

Version:
$Revision: 1.3 $, $Date: 1998/07/10 20:07:26 $
Author:
Marco da Silva (mds)

Variable Index

 o MT_TREE
Produces an empty tree which has only one external node.
 o NON_ROOT
a non root position
 o RANDOM
Produces a tree of random shape.
 o ROOT
the root of the tree
 o SAPLING
Produces a tree with three nodes, one internal and two external.
 o THREE
represents the three positions made in SAPLING.

Constructor Index

 o BinaryTreeFactory(String)
 o BinaryTreeFactory(String, String)

Method Index

 o build(Position, int)
Auxiliary method used to build a random tree that recursively builds a tree rooted at position p and with n external nodes.
 o generate(int, int)
Generates a data structure based on the type and position key.
 o init(String)
call to avoid null pointer exceptions, creates structures that take parameters.
 o location(int)
Returns the current container and a new location for that container
 o randomTree(int)
Uses the random tree generation code found in section 5.5 of Data Structures and Algorithms in Java.
 o setContainer(Object)
Sets the current container of the factory, so that the factory can generate locations like Position and Locator

Variables

 o MT_TREE
 public static final int MT_TREE
Produces an empty tree which has only one external node.

 o ROOT
 public static final int ROOT
the root of the tree

 o SAPLING
 public static final int SAPLING
Produces a tree with three nodes, one internal and two external.

 o THREE
 public static final int THREE
represents the three positions made in SAPLING.

 o RANDOM
 public static final int RANDOM
Produces a tree of random shape. Pass in the number of external nodes the tree is to have instead of a location. All of the positions will be returned. Uses expandExternal, isExternal, leftChild, and rightChild

 o NON_ROOT
 public static final int NON_ROOT
a non root position

Constructors

 o BinaryTreeFactory
 public BinaryTreeFactory(String structToBuild)
 o BinaryTreeFactory
 public BinaryTreeFactory(String structToBuild,
                          String arguments)

Methods

 o init
 public void init(String arguments)
call to avoid null pointer exceptions, creates structures that take parameters.

 o generate
 public TestStructure generate(int structure,
                               int location)
Generates a data structure based on the type and position key.

Overrides:
generate in class GenericFactory
 o location
 public TestStructure location(int location)
Returns the current container and a new location for that container

Overrides:
location in class GenericFactory
 o setContainer
 public void setContainer(Object container)
Sets the current container of the factory, so that the factory can generate locations like Position and Locator

Overrides:
setContainer in class GenericFactory
 o randomTree
 public BinaryTree randomTree(int externals)
Uses the random tree generation code found in section 5.5 of Data Structures and Algorithms in Java.

Parameters:
externals - The number of external nodes in the tree.
Returns:
a tree
 o build
 protected void build(Position p,
                      int n)
Auxiliary method used to build a random tree that recursively builds a tree rooted at position p and with n external nodes.

Parameters:
p - The root position.
n - The number of externals.

All Packages  Class Hierarchy  This Package  Previous  Next  Index