|
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
An abstract tree that has at most two children per node.
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
Field Summary | |
protected Object |
data
|
protected BinaryTree |
left
|
protected BinaryTree |
right
|
Constructor Summary | |
BinaryTree()
Default constructor, creates an empty binary tree. |
|
BinaryTree(Object data)
Creates a binary tree with the specified object at the root. |
|
BinaryTree(Object data,
BinaryTree left,
BinaryTree right)
Creates a binary tree with the specified object at the root. |
Method Summary | |
protected Object |
_data()
Retrieve the data at the root of this tree. |
protected BinaryTree |
_left()
Retrieve the left child of this tree. |
protected BinaryTree |
_right()
Retrieve the right child of this tree. |
protected void |
_setData(Object obj)
Set the value that this BinaryTree holds. |
protected void |
_setLeft(BinaryTree left)
Set the left subtree of this BinaryTree. |
protected void |
_setRight(BinaryTree right)
Set the right subtree of this BinaryTree. |
protected void |
add(Object obj)
Adds this object to the tree. |
boolean |
equals(Object obj)
|
boolean |
exists(Object obj)
See if the specified Object is in the tree or not. |
int |
getNumberOfElements()
Get the number of elements in this tree. |
Enumeration |
inOrderTraversal()
Get the elements of the tree through an in-order traversal. |
Enumeration |
postOrderTraversal()
Get the elements of the tree through an post-order traversal. |
Enumeration |
preOrderTraversal()
Get the elements of the tree through an pre-order traversal. |
protected void |
remove(Object obj)
Remove an object from this tree. |
String |
toString()
|
Methods inherited from class java.lang.Object |
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
protected Object data
protected BinaryTree left
protected BinaryTree right
Constructor Detail |
public BinaryTree()
public BinaryTree(Object data)
data
- is the value for the root of this BinaryTree.public BinaryTree(Object data, BinaryTree left, BinaryTree right)
data
- is the value for the root of this BinaryTree.left
- is the left subtree of this BinaryTree.right
- is the right subtree of this BinaryTree.Method Detail |
public boolean exists(Object obj)
obj
- is the Object to check for in the tree.protected void add(Object obj)
obj
- is the Object to add to the tree.protected void remove(Object obj)
obj
- is the Object to remove from the tree.public int getNumberOfElements()
protected Object _data()
This is an internal method. You can create another method named data() to return the right kind of object if necessary.
protected BinaryTree _left()
This is an internal method. You can create another method named left() to return the correct kind of BinaryTree if necessary.
protected BinaryTree _right()
This is an internal method. You can create another method named right() to return the correct kind of BinaryTree if necessary.
public Enumeration inOrderTraversal()
public Enumeration preOrderTraversal()
public Enumeration postOrderTraversal()
protected void _setLeft(BinaryTree left)
left
- is a BinaryTree that will be the left subtree.protected void _setRight(BinaryTree right)
right
- is a BinaryTree that will be the right subtree.protected void _setData(Object obj)
data
- is the value for the root of this BinaryTree.public boolean equals(Object obj)
equals
in class Object
public String toString()
toString
in class Object
|
Copyright Information | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |