Opus5
Interface Tree

All Superinterfaces:
Comparable, Container
All Known Subinterfaces:
SearchTree
All Known Implementing Classes:
AbstractTree, PartitionAsForest.PartitionTree

public interface Tree
extends Container

Encapsulates methods common to the nodes of a tree.

Version:
$Id: Tree.java,v 3.1 1998/07/28 01:32:17 brpreiss Exp $
Author:
Bruno R. Preiss, P.Eng.

Field Summary
static java.lang.String copyright
           
 
Method Summary
 void breadthFirstTraversal(Visitor visitor)
          Causes a visitor to visit the nodes of this tree in breadth-first traversal order starting from this node.
 void depthFirstTraversal(PrePostVisitor visitor)
          Causes a visitor to visit the nodes of this tree in depth-first traversal order starting from this node.
 int getDegree()
          Returns the degree of this tree node.
 int getHeight()
          Returns the height in the tree of this tree node.
 java.lang.Object getKey()
          Returns the object contained in this tree node.
 Tree getSubtree(int i)
          Returns the specified subtree of this tree node.
 boolean isEmpty()
          Tests if this tree node is empty (i.e., an external node).
 boolean isLeaf()
          Tests if this tree node is a leaf node.
 
Methods inherited from interface Opus5.Container
accept, getCount, getEnumeration, isFull, purge
 
Methods inherited from interface Opus5.Comparable
compare, isEQ, isGE, isGT, isLE, isLT, isNE
 

Field Detail

copyright

public static final java.lang.String copyright
Method Detail

getKey

public java.lang.Object getKey()
Returns the object contained in this tree node.
Returns:
The object contained in this tree node.
Throws:
InvalidOperationException - If this is an external node.

getSubtree

public Tree getSubtree(int i)
Returns the specified subtree of this tree node.
Parameters:
i - The number of the subtree to select.
Returns:
The specified subtree of this tree node.

isEmpty

public boolean isEmpty()
Tests if this tree node is empty (i.e., an external node).
Specified by:
isEmpty in interface Container
Returns:
True if this tree node is empty; false otherwise.

isLeaf

public boolean isLeaf()
Tests if this tree node is a leaf node. A leaf node is an internal node all the subtrees of which (if any) are external nodes.
Returns:
True if this is a leaf node; false otherwise.

getDegree

public int getDegree()
Returns the degree of this tree node. The degree of a node is the number of subtrees it has. The degree of an external node is zero.
Returns:
The degree of this tree node.

getHeight

public int getHeight()
Returns the height in the tree of this tree node. The height of a node is the length of the longest path from the node to a leaf. The height of an external node is -1.
Returns:
The height of this tree node.

depthFirstTraversal

public void depthFirstTraversal(PrePostVisitor visitor)
Causes a visitor to visit the nodes of this tree in depth-first traversal order starting from this node. This method invokes the PreVisit and PostVisit methods of the visitor for each node in this tree. The traversal continues as long as the IsDone method of the visitor returns false.
Parameters:
visitor - The visitor to accept.
See Also:
PrePostVisitor

breadthFirstTraversal

public void breadthFirstTraversal(Visitor visitor)
Causes a visitor to visit the nodes of this tree in breadth-first traversal order starting from this node. This method invokes the Visit method of the visitor for each node in this tree. The traversal continues as long as the IsDone method of the visitor returns false.
Parameters:
visitor - The visitor to accept.
See Also:
Visitor