|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectscranton.tree.PositionalBinaryTreeViaRecTreeWStk
A class that represents a positional binary tree with a recursive binary tree and a stack. The stack maintains the path from the root (bottom of the stack) to the current subtree (top of the stack).
| Field Summary | |
protected Stack |
Stk
The stack contains the path from the root (bottom of the stack) to the current tree (top of the stack). |
protected RecursiveBinaryTreeViaLinear1 |
T
The recursive binary tree used to represent the entire tree structure. |
| Constructor Summary | |
PositionalBinaryTreeViaRecTreeWStk()
Construct an empty tree. |
|
PositionalBinaryTreeViaRecTreeWStk(java.lang.Object root,
PositionalBinaryTreeViaRecTreeWStk left,
PositionalBinaryTreeViaRecTreeWStk right)
Construct a tree with a root and two subtrees. |
|
| Method Summary | |
PositionalBinaryTree |
factory()
|
java.lang.Object |
getNode()
Access the root of the current tree. |
void |
graft(PositionalBinaryTree Subtree)
Grafts a tree to the current position of the tree, which must be empty. |
boolean |
isEmpty()
Returns true if the current position is an empty tree. |
boolean |
isRoot()
Returns true iff the current position is the root fo the tree. |
PositionalBinaryTree |
prune()
Returns the subtree at the current position in the tree and makes the tree at the current position be empty. |
void |
setNode(java.lang.Object obj)
Replace the current root with obj |
void |
toLeftSubtree()
Navigates to the left subtree of the current tree. |
void |
toParent()
Navigates to the parent of the current tree. |
void |
toRightSubtree()
Navigates to the right subtree of the current tree. |
void |
toRoot()
Navigates to the root of the tree structure. |
java.lang.String |
toString()
Returns a parenthesized string representation of the tree at the current position. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
protected RecursiveBinaryTreeViaLinear1 T
protected Stack Stk
| Constructor Detail |
public PositionalBinaryTreeViaRecTreeWStk()
public PositionalBinaryTreeViaRecTreeWStk(java.lang.Object root,
PositionalBinaryTreeViaRecTreeWStk left,
PositionalBinaryTreeViaRecTreeWStk right)
| Method Detail |
public boolean isEmpty()
isEmpty in interface PositionalBinaryTreepublic boolean isRoot()
isRoot in interface PositionalBinaryTreepublic void toRoot()
toRoot in interface PositionalBinaryTreepublic void toParent()
toParent in interface PositionalBinaryTreepublic void toLeftSubtree()
toLeftSubtree in interface PositionalBinaryTreepublic void toRightSubtree()
toRightSubtree in interface PositionalBinaryTreepublic java.lang.Object getNode()
getNode in interface PositionalBinaryTreepublic void setNode(java.lang.Object obj)
setNode in interface PositionalBinaryTreeobj - New contents of the current rootpublic void graft(PositionalBinaryTree Subtree)
graft in interface PositionalBinaryTreeSubtree - Grafted to the current position in the treepublic PositionalBinaryTree prune()
prune in interface PositionalBinaryTreepublic PositionalBinaryTree factory()
public java.lang.String toString()
toString in interface PositionalBinaryTree
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||