|
UC Berkeley Group for User Interface Research Updated November 17, 2000 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--edu.berkeley.guir.lib.graphs.BinaryTree | +--edu.berkeley.guir.lib.graphs.BinarySearchTree
An tree that has at most two children per node ordered such that all values less than the root value will go to the left, and all values greater than the root value will go to the right.
It uses a Comparison object to determine where in the tree an object goes.
This software is distributed under the Berkeley Software License.
Revisions: - GUIRLib-v1.0-1.0.0, Nov 25 1997, JH Created class - GUIRLib-v1.0-1.1.0, Feb 24 2000, JH Updated for JDK1.3RC1 to use the Collections - GUIRLib-v1.2-1.0.0, Jun 22 2000, JH Touched for GUIRLib release - GUIRLib-v1.3-1.0.0, Aug 11 2000, JH Touched for GUIRLib release - GUIRLib-v1.4-1.0.0, Aug 31 2000, JH Touched for GUIRLib release
Comparison
,
NumComparison
Fields inherited from class edu.berkeley.guir.lib.graphs.BinaryTree |
data, left, right |
Constructor Summary | |
BinarySearchTree()
Default constructor, creates an empty binary tree. |
|
BinarySearchTree(Object data)
Creates a binary tree with the specified object at the root. |
Method Summary | |
void |
add(Object obj)
Add an object to this tree starting with the current node as root. |
protected Object |
data()
Get the data at the root of this BinarySearchTree. |
boolean |
exists(Object obj)
See if the specified Object is in the tree or not. |
boolean |
existsHelper(Object obj,
BinarySearchTree root)
See if the specified Object is in the specified tree or not. |
BinarySearchTree |
left()
Return the left subtree. |
BinarySearchTree |
right()
Return the right subtree. |
static void |
setComparison(Comparison aCompare)
Set the object that will be used to compare objects in this BinarySearchTree. |
protected void |
setData(Object obj)
Set the data at the root of this BinarySearchTree. |
static void |
setDuplicateFlag(boolean flag)
Allow duplicate values in the tree or not? By default, duplicate values are ignored. |
void |
setLeft(BinarySearchTree root)
|
static void |
setOverwriteFlag(boolean flag)
Overwrite duplicate values in the tree or not? By default, duplicate values are ignored. |
void |
setRight(BinarySearchTree root)
|
Methods inherited from class edu.berkeley.guir.lib.graphs.BinaryTree |
_data, _left, _right, _setData, _setLeft, _setRight, equals, getNumberOfElements, inOrderTraversal, postOrderTraversal, preOrderTraversal, remove, toString |
Methods inherited from class java.lang.Object |
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
public BinarySearchTree()
public BinarySearchTree(Object data)
data
- is the value for the root of this BinarySearchTree.Method Detail |
public static void setComparison(Comparison aCompare)
aCompare
- is the comparison object.public static void setOverwriteFlag(boolean flag)
flag
- is the value to set for Duplicate.public static void setDuplicateFlag(boolean flag)
flag
- is the value to set for Duplicate.protected void setData(Object obj)
obj
- is the object to add, which may not be null.public void add(Object obj)
add
in class BinaryTree
obj
- is the object to add, which may not be null.public void setLeft(BinarySearchTree root)
public void setRight(BinarySearchTree root)
protected Object data()
public boolean exists(Object obj)
exists
in class BinaryTree
obj
- is the Object to check for in the tree. If obj is null
then true will be returned always.public boolean existsHelper(Object obj, BinarySearchTree root)
obj
- is the Object to check for in the tree. If obj is null
then true will be returned always.root
- is the tree to check in.public BinarySearchTree left()
public BinarySearchTree right()
|
Copyright Information | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |