asd_library.tree.tree
Class TreeNode

java.lang.Object
  |
  +--asd_library.tree.tree.TreeNode

public class TreeNode
extends java.lang.Object

Basic node stored in a binary search tree.


Field Summary
 TreeNode firstChild
          The first child node of current node.
 java.lang.Comparable key
          The key of the node.
 TreeNode nextSibling
          The next sibling of current node
 TreeNode parent
          The parent of this node
 
Constructor Summary
TreeNode()
          Constructs a new node.
TreeNode(java.lang.Comparable el)
          Constructs a new node.
TreeNode(java.lang.Comparable el, TreeNode par, TreeNode fc, TreeNode ns)
          Constructs a new node.
 
Method Summary
 TreeNode getFirstChild()
          Returns the first child of the node.
 java.lang.Comparable getKey()
          Returns the key of the node.
 TreeNode getNextSibling()
          Returns the next sibling of the node.
 TreeNode getParent()
          Returns the parent of the node.
 boolean isLeaf()
          Verifies if this TreeNode is a leaf.
 void setParent(TreeNode par)
          Sets the parent of this node to be the specified node.
 void visit()
          Prints the String that represents the key of hte node.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

key

public java.lang.Comparable key
The key of the node.


firstChild

public TreeNode firstChild
The first child node of current node.


nextSibling

public TreeNode nextSibling
The next sibling of current node


parent

public TreeNode parent
The parent of this node

Constructor Detail

TreeNode

public TreeNode()
Constructs a new node.


TreeNode

public TreeNode(java.lang.Comparable el)
Constructs a new node.

Parameters:
el - the element to insert.

TreeNode

public TreeNode(java.lang.Comparable el,
                TreeNode par,
                TreeNode fc,
                TreeNode ns)
Constructs a new node.

Parameters:
el - the element to insert.
par - the parent of this node.
fc - the first child of this node.
ns - the next sibling of this node.
Method Detail

getKey

public java.lang.Comparable getKey()
Returns the key of the node.

Returns:
the key of this node

getFirstChild

public TreeNode getFirstChild()
Returns the first child of the node.

Returns:
the first child TreeNode.

getNextSibling

public TreeNode getNextSibling()
Returns the next sibling of the node.

Returns:
the next sibling TreeNode.

getParent

public TreeNode getParent()
Returns the parent of the node.

Returns:
the parent TreeNode.

setParent

public void setParent(TreeNode par)
Sets the parent of this node to be the specified node.

Parameters:
par - what the parent field is to be set to.

visit

public void visit()
Prints the String that represents the key of hte node.


isLeaf

public boolean isLeaf()
Verifies if this TreeNode is a leaf.

Returns:
true if this node is a leaf, false otherwise.