|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--gshute.trees.Tree
A Tree is a binary tree with a cursor. The cursor is a TreeEdge that can be moved around in the tree. Nodes can be replaced, added, or removed at the cursor to position.
Field Summary | |
protected TreeEdge |
cursor
cursor is the cursor edge for this tree. |
protected java.lang.reflect.Constructor |
nodeConstructor
nodeConstructor is the node constructor for this tree. |
protected TreeNode |
root
root is the root of this tree. |
protected java.lang.StringBuffer |
stringBuffer
stringBuffer is the string buffer used by this tree for building its toString() returned value. |
Constructor Summary | |
Tree(java.lang.Class nc)
new Tree(nc) returns an empty binary tree whose nodes are constructed from class nc. |
Method Summary | |
void |
add(java.lang.Object d)
t.add(d) modifies t, adding a node with data d at the cursor to position of t. |
protected void |
addSubtreeString(TreeNode n,
int l,
int sz)
addSubtreeString(n, l, sz) adds a string to stringBuffer. |
boolean |
containsNode(TreeNode n)
t.containsNode() returns true if n is a node in t. |
TreeEdge |
getCursor()
t.getCursor() returns the cursor of t. |
TreeNode |
getCursorTo()
t.getCursorTo() returns the cursor to node of t. |
java.util.Iterator |
getInorderIterator()
t.getInorderIterator() returns an inorder iterator for the data in t. |
java.util.Iterator |
getPostorderIterator()
t.getPostorderIterator() returns a postorder iterator for the data in t. |
java.util.Iterator |
getPreorderIterator()
t.getPreorderIterator() returns a preorder iterator for the data in t. |
TreeNode |
getRoot()
t.getRoot() returns the root of t. |
boolean |
isEmpty()
t.isEmpty() returns true if t is empty. |
void |
remove()
t.remove() removes the data at the to node of the cursor of t. |
void |
replace(TreeEdge tl,
TreeNode n)
t.replace(n) modifies t, replacing the cursor to node of t by n. |
void |
rotateLeft(TreeNode n)
t.rotateLeft(n) performs a left rotation in t at n. |
void |
rotateRight(TreeNode n)
t.rotateRight(n) performs a right rotation in t at n. |
void |
setRoot(TreeNode rn)
t.setRoot(rn) makes rn the root node of t. |
java.lang.String |
toString()
t.toString() returns a string that describes t and its data, using an indent size of 6 between different levels of t. |
java.lang.String |
toString(int sz)
t.toString(sz) returns a string that describes t and its data, using an indent size of sz between different levels of t. |
Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
wait,
wait,
wait |
Field Detail |
protected TreeNode root
protected TreeEdge cursor
protected java.lang.reflect.Constructor nodeConstructor
protected java.lang.StringBuffer stringBuffer
Constructor Detail |
public Tree(java.lang.Class nc)
Preconditions: TreeNode.class.isAssignableFrom(c) is true.
Method Detail |
public boolean isEmpty()
public TreeNode getRoot()
public TreeNode getCursorTo()
public TreeEdge getCursor()
public boolean containsNode(TreeNode n)
public void setRoot(TreeNode rn)
public void replace(TreeEdge tl, TreeNode n)
public void add(java.lang.Object d)
Preconditions:
t.getCursor().getTo() == null
public void remove()
Preconditions:
t.getCursor().getTo() != null
public void rotateLeft(TreeNode n)
public void rotateRight(TreeNode n)
public java.util.Iterator getPreorderIterator()
public java.util.Iterator getInorderIterator()
public java.util.Iterator getPostorderIterator()
protected void addSubtreeString(TreeNode n, int l, int sz)
public java.lang.String toString()
public java.lang.String toString(int sz)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |