org.locomotive.util.data
Class DataTree.TreeNode

java.lang.Object
  |
  +--org.locomotive.util.data.DataTree.TreeNode
Enclosing class:
DataTree

protected class DataTree.TreeNode
extends java.lang.Object

a node for a binary search tree


Constructor Summary
DataTree.TreeNode(ComparisonKey data)
          Constructor for Nodes with keys as data
DataTree.TreeNode(ComparisonKey key, java.lang.Object data)
          Constructor takes a key and it's corresponding data
 
Method Summary
 int compare(DataTree.TreeNode node)
          Convenience method for comparing the keys of two tree nodes
 java.lang.Object getData()
          access data
 ComparisonKey getKey()
          Access key
 DataTree.TreeNode getLeftChild()
           
 DataTree.TreeNode getParent()
          Access parent
 DataTree.TreeNode getRightChild()
           
 boolean hasNoChildren()
          returns true if node has no children
 boolean leafNode()
          returns true if node is a leaf node (if node has < 2 children)
 java.lang.Object returnData()
          returns the data contained in the node: either node.data or node.key if node.data is null
 void setData(java.lang.Object newData)
          Change data
 void setKey(ComparisonKey newKey)
          Change key
 void setLeftChild(DataTree.TreeNode newChild)
          Set left child of this node and parent pointer of new left child.
 void setRightChild(DataTree.TreeNode newChild)
          Set right child of this node and parent pointer of new right child.
 void swapData(DataTree.TreeNode node)
          Swap data with another node
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DataTree.TreeNode

public DataTree.TreeNode(ComparisonKey key,
                         java.lang.Object data)
Constructor takes a key and it's corresponding data

DataTree.TreeNode

public DataTree.TreeNode(ComparisonKey data)
Constructor for Nodes with keys as data
Method Detail

compare

public int compare(DataTree.TreeNode node)
            throws ComparisonKeyException
Convenience method for comparing the keys of two tree nodes

getKey

public ComparisonKey getKey()
Access key

getData

public java.lang.Object getData()
access data

getParent

public DataTree.TreeNode getParent()
Access parent

getLeftChild

public DataTree.TreeNode getLeftChild()

getRightChild

public DataTree.TreeNode getRightChild()

hasNoChildren

public boolean hasNoChildren()
returns true if node has no children

leafNode

public boolean leafNode()
returns true if node is a leaf node (if node has < 2 children)

returnData

public java.lang.Object returnData()
returns the data contained in the node: either node.data or node.key if node.data is null

setKey

public void setKey(ComparisonKey newKey)
Change key

setData

public void setData(java.lang.Object newData)
Change data

swapData

public void swapData(DataTree.TreeNode node)
Swap data with another node

setLeftChild

public void setLeftChild(DataTree.TreeNode newChild)
Set left child of this node and parent pointer of new left child.

setRightChild

public void setRightChild(DataTree.TreeNode newChild)
Set right child of this node and parent pointer of new right child.

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object