learner
Class Tree

java.lang.Object
  extended by learner.Tree

public class Tree
extends java.lang.Object

Represents ordered, labelled trees.


Field Summary
protected  RankedSymbol root
          The ranked symbol that consitutes this node.
protected  java.util.Vector<Tree> subtrees
          The subtrees of the current node.
 
Constructor Summary
Tree(RankedSymbol root, java.util.Vector<Tree> subtrees)
          Constructs a new labelled tree with root node root and subtrees as defined by subtrees.
Tree(java.lang.String tree)
          Constructs a new labelled tree from a string.
 
Method Summary
 java.lang.Object clone()
           
 boolean equals(java.lang.Object o)
           
 boolean equals(Tree t)
           
 RankedSymbol getRoot()
          Getter function for the root label.
 java.util.Vector<Tree> getSubtrees()
           
 int hashCode()
           
 int size()
           
 Tree subst(Tree tree)
          Replaces every occurence of the special symbol "O" with the labelled tree tree.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

subtrees

protected java.util.Vector<Tree> subtrees
The subtrees of the current node.


root

protected RankedSymbol root
The ranked symbol that consitutes this node.

Constructor Detail

Tree

public Tree(RankedSymbol root,
            java.util.Vector<Tree> subtrees)
Constructs a new labelled tree with root node root and subtrees as defined by subtrees.

Parameters:
root - a ranked symbol
subtrees - a vector of labelled trees, whose lengths equals the rank of root

Tree

public Tree(java.lang.String tree)
Constructs a new labelled tree from a string. Acts as a wrapper function for private member Tree(String).

Parameters:
tree - A String description of the labelled tree that is to be constructed. It is very important that the string is correctly formatted, as the validation performed by the function itself is leaves a lot to wish for.
Method Detail

clone

public java.lang.Object clone()
Overrides:
clone in class java.lang.Object

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

equals

public boolean equals(Tree t)

equals

public boolean equals(java.lang.Object o)
Overrides:
equals in class java.lang.Object

toString

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

getRoot

public RankedSymbol getRoot()
Getter function for the root label.

Returns:
returns the ranked symbol that consitutes the root of this tree.

getSubtrees

public java.util.Vector<Tree> getSubtrees()

subst

public Tree subst(Tree tree)
Replaces every occurence of the special symbol "O" with the labelled tree tree.

Parameters:
tree - The tree that is to be substituted into this context.
Returns:
The resulting tree with the substitution performed.

size

public int size()