gshute.trees
Class TreeNode

java.lang.Object
  |
  +--gshute.trees.TreeNode

public class TreeNode
extends java.lang.Object

A TreeNode is a node in a binary tree.


Field Summary
 java.lang.Object data
          data is the data held by this node.
 TreeNode left
          left is the left child of this node.
 TreeNode parent
          parent is the parent of this node.
 TreeNode right
          right is the right child of this node.
 
Constructor Summary
TreeNode(java.lang.Object d)
          new TreeNode(Object d) returns a new tree node with data d.
 
Method Summary
 void afterAdd(TreeEdge e)
          n.afterAdd(e) performs modifications that are needed after n is added as the to node of e.
 void afterRemove(TreeEdge e)
          n.afterRemove(e) performs modifications that are needed after n is removed as the to node of e.
 java.lang.Object getData()
          n.getData() returns the data held by n.
 TreeNode getLeft()
          n.getLeft() returns the left child of n.
 TreeNode getParent()
          n.getParent() returns the parent of n.
 TreeNode getRight()
          n.getRight() returns the right child of n.
 void preRotateLeft()
          n.preRotateLeft() performs checks and modifications that are needed prior to a structural left rotation.
 void preRotateRight()
          n.preRotateRight() performs checks and modifications that are needed prior to a structural right rotation.
 void setData(java.lang.Object d)
          n.getData(d) sets the data held by n to d.
 void setLeft(TreeNode l)
          n.setLeft(l) makes l the left child of n.
 void setRight(TreeNode r)
          n.setRight(r) makes r the right child of n.
 java.lang.String toString()
          n.toString() returns a string that describes n and its data.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

left

public TreeNode left
left is the left child of this node.

right

public TreeNode right
right is the right child of this node.

parent

public TreeNode parent
parent is the parent of this node.

data

public java.lang.Object data
data is the data held by this node.
Constructor Detail

TreeNode

public TreeNode(java.lang.Object d)
new TreeNode(Object d) returns a new tree node with data d. Both subtrees of the new node are empty.
Method Detail

getLeft

public TreeNode getLeft()
n.getLeft() returns the left child of n.

getRight

public TreeNode getRight()
n.getRight() returns the right child of n.

getParent

public TreeNode getParent()
n.getParent() returns the parent of n.

getData

public java.lang.Object getData()
n.getData() returns the data held by n.

setLeft

public void setLeft(TreeNode l)
n.setLeft(l) makes l the left child of n. If l is not null then n is made the parent of l.

setRight

public void setRight(TreeNode r)
n.setRight(r) makes r the right child of n. If r is not null then n is made the parent of r.

setData

public void setData(java.lang.Object d)
n.getData(d) sets the data held by n to d.

preRotateLeft

public void preRotateLeft()
n.preRotateLeft() performs checks and modifications that are needed prior to a structural left rotation.

preRotateRight

public void preRotateRight()
n.preRotateRight() performs checks and modifications that are needed prior to a structural right rotation.

afterAdd

public void afterAdd(TreeEdge e)
n.afterAdd(e) performs modifications that are needed after n is added as the to node of e.

afterRemove

public void afterRemove(TreeEdge e)
n.afterRemove(e) performs modifications that are needed after n is removed as the to node of e.

toString

public java.lang.String toString()
n.toString() returns a string that describes n and its data.
Overrides:
toString in class java.lang.Object