|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||
java.lang.Object
|
+--Opus5.AbstractObject
|
+--Opus5.AbstractContainer
|
+--Opus5.AbstractTree
|
+--Opus5.BinaryTree
A node in a binary tree.
| Inner classes inherited from class Opus5.AbstractTree |
AbstractTree.TreeEnumeration |
| Field Summary | |
protected java.lang.Object |
key
The key in this node. |
protected BinaryTree |
left
The the left subtree of this node. |
protected BinaryTree |
right
The the right subtree of this node. |
| Fields inherited from class Opus5.AbstractContainer |
count |
| Fields inherited from interface Opus5.Tree |
copyright |
| Constructor Summary | |
BinaryTree()
Constructs an empty BinaryTree. |
|
BinaryTree(java.lang.Object key)
Constructs a BinaryTree with the specified key. |
|
BinaryTree(java.lang.Object key,
BinaryTree left,
BinaryTree right)
Constructs a BinaryTree with the specified key,
and the specified left and right subtree. |
|
| Method Summary | |
void |
attachKey(java.lang.Object object)
Attaches the specified object as the key of this node. |
void |
attachLeft(BinaryTree t)
Attaches the specified binary tree as the left subtree of this node. |
void |
attachRight(BinaryTree t)
Attaches the specified binary tree as the right subtree of this node. |
protected int |
compareTo(Comparable object)
Compares this binary tree with the specified comparable object. |
void |
depthFirstTraversal(PrePostVisitor visitor)
Causes a visitor to visit the nodes of this tree in depth-first traversal order starting from this node. |
java.lang.Object |
detachKey()
Detaches the key from this node; making it the empty node. |
BinaryTree |
detachLeft()
Detaches and returns the left subtree of this node. |
BinaryTree |
detachRight()
Detaches and returns the right subtree of this node. |
int |
getDegree()
Returns the degree of this node. |
java.lang.Object |
getKey()
Returns the key in this node. |
BinaryTree |
getLeft()
Returns the left subtree of this node. |
BinaryTree |
getRight()
Returns the right subtree of this node. |
Tree |
getSubtree(int i)
Returns the specified subtree of this node. |
boolean |
isEmpty()
Tests whether this node is empty. |
boolean |
isLeaf()
Tests whether this node is a leaf node. |
void |
purge()
Purges this binary tree node, making it empty. |
| Methods inherited from class Opus5.AbstractTree |
accept, breadthFirstTraversal, getCount, getEnumeration, getHeight |
| Methods inherited from class Opus5.AbstractContainer |
hashCode, isFull, toString |
| Methods inherited from class Opus5.AbstractObject |
compare, equals, isEQ, isGE, isGT, isLE, isLT, isNE |
| Methods inherited from class java.lang.Object |
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface Opus5.Container |
isFull |
| Methods inherited from interface Opus5.Comparable |
compare, isEQ, isGE, isGT, isLE, isLT, isNE |
| Field Detail |
protected java.lang.Object key
protected BinaryTree left
protected BinaryTree right
| Constructor Detail |
public BinaryTree(java.lang.Object key,
BinaryTree left,
BinaryTree right)
BinaryTree with the specified key,
and the specified left and right subtree.key - The key in this node.left - The left subtree of this node.right - The left subtree of this node.public BinaryTree()
BinaryTree.public BinaryTree(java.lang.Object key)
BinaryTree with the specified key.
The left and right subtrees default to empty trees.| Method Detail |
public void purge()
public boolean isLeaf()
public int getDegree()
2 if this node is non-empty;
0 otherwise.public boolean isEmpty()
isEmpty in class AbstractContainerpublic java.lang.Object getKey()
InvalidOperationException - If this node is empty.public Tree getSubtree(int i)
i - The number of the subtree to return.public void attachKey(java.lang.Object object)
object - The key to attach.InvalidOperationException - If this node is not empty.public java.lang.Object detachKey()
InvalidOperationException - If this is not a leaf node.public BinaryTree getLeft()
InvalidOperationException - If this node is empty.public void attachLeft(BinaryTree t)
t - The new left subtree of this node.InvalidOperationException - If this node is empty or if this node is node empty
and the left subtree is also not empty.public BinaryTree detachLeft()
InvalidOperationException - If this node is empty.public BinaryTree getRight()
InvalidOperationException - If this node is empty.public void attachRight(BinaryTree t)
t - The new right subtree of this node.InvalidOperationException - If this node is empty or if this node is node empty
and the right subtree is also not empty.public BinaryTree detachRight()
InvalidOperationException - If this node is empty.public void depthFirstTraversal(PrePostVisitor visitor)
preVisit, inVisit
and postVisit methods of the visitor
for each node in this tree.depthFirstTraversal in class AbstractTreevisitor - The visitor to accept.protected int compareTo(Comparable object)
BinaryTreecompareTo in class AbstractObjectobject - The comparable object with which to compare this
binar tree.
|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||