Opus5
Class GeneralTree
java.lang.Object
|
+--Opus5.AbstractObject
|
+--Opus5.AbstractContainer
|
+--Opus5.AbstractTree
|
+--Opus5.GeneralTree
- All Implemented Interfaces:
- Comparable, Container, Tree
- Direct Known Subclasses:
- BinomialQueue.BinomialTree
- public class GeneralTree
- extends AbstractTree
A node in a general tree.
- Version:
- $Id: GeneralTree.java,v 3.3 1999/02/03 14:12:29 brpreiss Exp $
- Author:
- Bruno R. Preiss, P.Eng.
|
Field Summary |
protected int |
degree
The degree of this node. |
protected java.lang.Object |
key
The key in this node. |
protected LinkedList |
list
A linked list of the subtrees of this node. |
|
Constructor Summary |
GeneralTree(java.lang.Object key)
Constructs a GeneralTree with the specified key. |
|
Method Summary |
void |
attachSubtree(GeneralTree t)
Attches the specified subtree to this general tree node. |
protected int |
compareTo(Comparable arg)
Compares this general tree with the specified comparable object. |
GeneralTree |
detachSubtree(GeneralTree t)
Detaches and returns the specified subtree of this general tree node. |
int |
getDegree()
Returns the degree of this node. |
java.lang.Object |
getKey()
Returns the key of this general tree node. |
Tree |
getSubtree(int i)
Returns the specified subtree of this general tree node. |
boolean |
isEmpty()
Tests whether this general tree node is empty. |
boolean |
isLeaf()
Tests whether this general tree nodes is a leaf node. |
void |
purge()
Purges this general tree node, making it empty. |
| Methods inherited from class java.lang.Object |
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
key
protected java.lang.Object key
- The key in this node.
degree
protected int degree
- The degree of this node.
list
protected LinkedList list
- A linked list of the subtrees of this node.
GeneralTree
public GeneralTree(java.lang.Object key)
- Constructs a
GeneralTree with the specified key.
- Parameters:
key - The desired key.
purge
public void purge()
- Purges this general tree node, making it empty.
isEmpty
public boolean isEmpty()
- Tests whether this general tree node is empty.
- Overrides:
isEmpty in class AbstractContainer
- Returns:
- False always.
isLeaf
public boolean isLeaf()
- Tests whether this general tree nodes is a leaf node.
- Returns:
- True if the degree of this node is zero;
false otherwise.
getDegree
public int getDegree()
- Returns the degree of this node.
- Returns:
- The degree of this node.
getKey
public java.lang.Object getKey()
- Returns the key of this general tree node.
- Returns:
- the key of this general tree node.
getSubtree
public Tree getSubtree(int i)
- Returns the specified subtree of this general tree node.
- Returns:
- The desired subtree of this tree node.
attachSubtree
public void attachSubtree(GeneralTree t)
- Attches the specified subtree to this general tree node.
- Parameters:
t - The subtree to attach.
detachSubtree
public GeneralTree detachSubtree(GeneralTree t)
- Detaches and returns the specified subtree of this general tree node.
- Parameters:
t - The subtree to detach.
compareTo
protected int compareTo(Comparable arg)
- Compares this general tree with the specified comparable object.
This method is not implemented.
- Overrides:
compareTo in class AbstractObject
- Parameters:
arg - The comparable object with which to compare this tree.- Throws:
MethodNotImplemented - Always.