|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.jikesrvm.compilers.opt.util.Tree
public class Tree
This class is a generic tree. It uses TreeNode and some enumeration classes.
Field Summary | |
---|---|
private TreeNode |
root
A tree is simply a pointer to the root |
Constructor Summary | |
---|---|
Tree()
constructor where the root is not initially known |
|
Tree(TreeNode node)
constructor where the root is initially known |
Method Summary | |
---|---|
private StringBuffer |
DFS(StringBuffer sb,
TreeNode node,
int depth)
A preorder depth first traversal, printing node as visited |
Enumeration<TreeNode> |
elements()
Provides an undefined enumeration over all elements in the tree |
Enumeration<TreeNode> |
getBottomUpEnumerator()
Provides a bottom-up enumeration over all elements in the tree |
TreeNode |
getRoot()
Gets the root of the tree |
Enumeration<TreeNode> |
getTopDownEnumerator()
Provides a top-down enumeration over all elements in the tree |
boolean |
isEmpty()
Is the tree empty? |
int |
numberOfNodes()
Counts and returns the number of nodes |
void |
setRoot(TreeNode node)
Sets the root of the tree to be the passed node. |
String |
toString()
Prints the tree |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
private TreeNode root
Constructor Detail |
---|
public Tree()
public Tree(TreeNode node)
node
- Root of the tree.Method Detail |
---|
public final boolean isEmpty()
public final TreeNode getRoot()
public final void setRoot(TreeNode node)
public final Enumeration<TreeNode> elements()
public final int numberOfNodes()
public final Enumeration<TreeNode> getBottomUpEnumerator()
public final Enumeration<TreeNode> getTopDownEnumerator()
public final String toString()
toString
in class Object
private StringBuffer DFS(StringBuffer sb, TreeNode node, int depth)
sb
- the string buffer to insert the resultsnode
- the node to processdepth
- the current depth (root = 0) in the tree
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |