org.jscience.util
Class BinaryTree

java.lang.Object
  extended by org.jscience.util.BinaryTree
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, Tree

public class BinaryTree
extends java.lang.Object
implements Tree, Cloneable, java.io.Serializable

A class representing a tree data structure with exactly 2 child elements or none.

See Also:
Serialized Form

Constructor Summary
BinaryTree()
          Creates a new BinaryTree object.
BinaryTree(java.lang.Object o)
          Creates a new BinaryTree object.
 
Method Summary
 java.lang.Object clone()
          DOCUMENT ME!
 boolean equals(java.lang.Object o)
          DOCUMENT ME!
static BinaryTree extractBinaryTree(BinaryTree tree1, BinaryTree tree2)
          DOCUMENT ME!
 java.util.Set getAllChildren()
          DOCUMENT ME!
 java.util.Set getChildren()
          DOCUMENT ME!
static BinaryTree getCommonRoot(BinaryTree tree1, BinaryTree tree2)
          DOCUMENT ME!
 java.lang.Object getContents()
          DOCUMENT ME!
 int getDepth()
          DOCUMENT ME!
 BinaryTree getLeftChild()
          DOCUMENT ME!
static java.util.Vector getLineage(BinaryTree tree1, BinaryTree tree2)
          DOCUMENT ME!
 BinaryTree getParent()
          DOCUMENT ME!
 BinaryTree getRightChild()
          DOCUMENT ME!
 BinaryTree getRoot()
          DOCUMENT ME!
static BinaryTree getRoot(BinaryTree tree)
          DOCUMENT ME!
 boolean hasChild()
          DOCUMENT ME!
 boolean hasChild(BinaryTree child)
          DOCUMENT ME!
 boolean hasDistantChild(BinaryTree child)
           
 boolean hasParent()
          DOCUMENT ME!
 void removeChild(BinaryTree child)
          DOCUMENT ME!
 void setChildren(BinaryTree child1, BinaryTree child2)
          DOCUMENT ME!
 void setChildren(java.util.Set children)
          DOCUMENT ME!
 void setContents(java.lang.Object obj)
          DOCUMENT ME!
 void setLeftChild(BinaryTree child)
          DOCUMENT ME!
 void setRightChild(BinaryTree child)
          DOCUMENT ME!
 
Methods inherited from class java.lang.Object
finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BinaryTree

public BinaryTree()
Creates a new BinaryTree object.


BinaryTree

public BinaryTree(java.lang.Object o)
Creates a new BinaryTree object.

Parameters:
o - DOCUMENT ME!
Method Detail

getContents

public java.lang.Object getContents()
DOCUMENT ME!

Specified by:
getContents in interface Tree
Returns:
DOCUMENT ME!

setContents

public void setContents(java.lang.Object obj)
DOCUMENT ME!

Parameters:
obj - DOCUMENT ME!

hasChild

public boolean hasChild()
DOCUMENT ME!

Returns:
DOCUMENT ME!

hasChild

public boolean hasChild(BinaryTree child)
DOCUMENT ME!

Parameters:
child - DOCUMENT ME!
Returns:
DOCUMENT ME!

getChildren

public java.util.Set getChildren()
DOCUMENT ME!

Specified by:
getChildren in interface Tree
Returns:
DOCUMENT ME!

getLeftChild

public BinaryTree getLeftChild()
DOCUMENT ME!

Returns:
DOCUMENT ME!

getRightChild

public BinaryTree getRightChild()
DOCUMENT ME!

Returns:
DOCUMENT ME!

setChildren

public void setChildren(java.util.Set children)
                 throws CircularReferenceException
DOCUMENT ME!

Parameters:
children - DOCUMENT ME!
Throws:
CircularReferenceException - DOCUMENT ME!
java.lang.IllegalArgumentException - DOCUMENT ME!

setChildren

public void setChildren(BinaryTree child1,
                        BinaryTree child2)
                 throws CircularReferenceException
DOCUMENT ME!

Parameters:
child1 - DOCUMENT ME!
child2 - DOCUMENT ME!
Throws:
CircularReferenceException - DOCUMENT ME!

setLeftChild

public void setLeftChild(BinaryTree child)
                  throws CircularReferenceException
DOCUMENT ME!

Parameters:
child - DOCUMENT ME!
Throws:
CircularReferenceException - DOCUMENT ME!
java.lang.IllegalArgumentException - DOCUMENT ME!

setRightChild

public void setRightChild(BinaryTree child)
                   throws CircularReferenceException
DOCUMENT ME!

Parameters:
child - DOCUMENT ME!
Throws:
CircularReferenceException - DOCUMENT ME!
java.lang.IllegalArgumentException - DOCUMENT ME!

removeChild

public void removeChild(BinaryTree child)
DOCUMENT ME!

Parameters:
child - DOCUMENT ME!
Throws:
java.lang.IllegalArgumentException - DOCUMENT ME!

hasParent

public boolean hasParent()
DOCUMENT ME!

Returns:
DOCUMENT ME!

getParent

public BinaryTree getParent()
DOCUMENT ME!

Returns:
DOCUMENT ME!

getDepth

public int getDepth()
DOCUMENT ME!

Returns:
DOCUMENT ME!

getRoot

public BinaryTree getRoot()
DOCUMENT ME!

Returns:
DOCUMENT ME!

getRoot

public static BinaryTree getRoot(BinaryTree tree)
DOCUMENT ME!

Parameters:
tree - DOCUMENT ME!
Returns:
DOCUMENT ME!

getCommonRoot

public static BinaryTree getCommonRoot(BinaryTree tree1,
                                       BinaryTree tree2)
DOCUMENT ME!

Parameters:
tree1 - DOCUMENT ME!
tree2 - DOCUMENT ME!
Returns:
DOCUMENT ME!

getLineage

public static java.util.Vector getLineage(BinaryTree tree1,
                                          BinaryTree tree2)
DOCUMENT ME!

Parameters:
tree1 - DOCUMENT ME!
tree2 - DOCUMENT ME!
Returns:
DOCUMENT ME!

extractBinaryTree

public static BinaryTree extractBinaryTree(BinaryTree tree1,
                                           BinaryTree tree2)
DOCUMENT ME!

Parameters:
tree1 - DOCUMENT ME!
tree2 - DOCUMENT ME!
Returns:
DOCUMENT ME!

getAllChildren

public java.util.Set getAllChildren()
DOCUMENT ME!

Returns:
DOCUMENT ME!

hasDistantChild

public boolean hasDistantChild(BinaryTree child)

equals

public boolean equals(java.lang.Object o)
DOCUMENT ME!

Overrides:
equals in class java.lang.Object
Parameters:
o - DOCUMENT ME!
Returns:
DOCUMENT ME!

clone

public java.lang.Object clone()
DOCUMENT ME!

Overrides:
clone in class java.lang.Object
Returns:
DOCUMENT ME!
See Also:
Object.clone()