ter.util
Class Tree

java.lang.Object
  |
  +--ter.util.Tree

public class Tree
extends java.lang.Object

Title: Tree

Description: A basic implementation of a biColored-tree of String

Copyright: Copyright (c) 2003

Company: UNICE

Version:
1.0
Author:
Zerbib Gabriel - Charbit Lucas - Galbois Xavier - Gahide Jérôme

Constructor Summary
Tree()
          Construct a new empty Tree.
 
Method Summary
 Tree getLeftChild()
          This function return the leftChild.
 Tree getRightChild()
          This function return the rightChild.
 java.lang.String getValue()
           
 boolean is_empty()
          the tree is empty if the left child, the right child and the value are null.
 boolean is_leaf()
          the tree is a leaf if the left child, the right child are null but not the value.
static java.lang.String leftCourse(Tree t)
          This function do the navigation by the left on the tree t.
 void setLeftChild(Tree tree)
          This procedure set the leftChild of the tree.
 void setRightChild(Tree tree)
          This procedure set the rightChild of the tree.
 void setValue(java.lang.String value)
          Set the root or leaf value for this tree.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Tree

public Tree()
Construct a new empty Tree.

Method Detail

getValue

public java.lang.String getValue()
                          throws java.lang.Exception
Returns:
the value root of the tree or the leaf value.
Throws:
java.lang.Exception - if the tree is empty

setValue

public void setValue(java.lang.String value)
Set the root or leaf value for this tree.

Parameters:
value - the string to set.

is_empty

public boolean is_empty()
the tree is empty if the left child, the right child and the value are null.

Returns:
true if the tree is empty.

is_leaf

public boolean is_leaf()
the tree is a leaf if the left child, the right child are null but not the value.

Returns:
true if the tree is a leaf.

getLeftChild

public Tree getLeftChild()
This function return the leftChild. NB : null if there is no leftChild.

Returns:
the leftChild

getRightChild

public Tree getRightChild()
This function return the rightChild. NB : null if there is no rightChild.

Returns:
the rightChild

setLeftChild

public void setLeftChild(Tree tree)
This procedure set the leftChild of the tree.

Parameters:
tree - the to get the leftChild NB : the tree must not to be null.

setRightChild

public void setRightChild(Tree tree)
This procedure set the rightChild of the tree.

Parameters:
tree - the to get the rightChild NB : the tree must not to be null.

leftCourse

public static java.lang.String leftCourse(Tree t)
This function do the navigation by the left on the tree t.

Parameters:
t - the tree to course.
Returns:
the String retpresentation of the tree by the left course. Ex: (+ 4 (- 3 2)) == 4 + (3 - 2)

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object
Returns:
a string representation of the tree (node leaf ).