org.uacalc.terms
Class VariableImp

java.lang.Object
  extended by org.uacalc.terms.VariableImp
All Implemented Interfaces:
Term, Variable

public class VariableImp
extends java.lang.Object
implements Variable

The term graph; that is, term tree with possibly shared nodes. This graph is acyclic.


Field Summary
 
Fields inherited from interface org.uacalc.terms.Variable
x, y, z
 
Constructor Summary
VariableImp(java.lang.String name)
           
 
Method Summary
 int depth()
          The depth of the term tree.
 boolean equals(java.lang.Object obj)
           
 java.lang.Object eval(Algebra alg, java.util.Map map)
          The evaluation of this term in an algebra using map as the variable assignment.
 java.util.List<Term> getChildren()
          A list of terms which are the immediate children.
 java.lang.String getName()
          The list of the variables for the language of this term.
 java.util.List getVariableList()
          The list of variables in the order they appear in the term.
 int hashCode()
           
 TermOperation interpretation(SmallAlgebra alg)
          The operation obtained from this term using the variables in the order they occur.
 Operation interpretation(SmallAlgebra alg, java.util.List<Variable> varlist, boolean all)
          The interpretation of this term in an algebra; that is, the operation on alg corresponding to this term.
 int intEval(Algebra alg, java.util.Map map)
          The int evaluation of this term in an algebra using map as the variable assignment.
 boolean isaVariable()
           
 OperationSymbol leadingOperationSymbol()
          The leading operation symbol or null if this term is a variable.
 int length()
          The length of the term.
 Term substitute(java.util.Map<Variable,Term> map)
          Replace some of the variables with terms.
 java.lang.String toString()
          A reasonably good printout of the term.
 java.lang.StringBuffer writeStringBuffer(java.lang.StringBuffer sb)
          This is really an efficiency helper for toString.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

VariableImp

public VariableImp(java.lang.String name)
Method Detail

getName

public java.lang.String getName()
The list of the variables for the language of this term.

Specified by:
getName in interface Variable

equals

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

hashCode

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

isaVariable

public boolean isaVariable()
Specified by:
isaVariable in interface Term

getChildren

public java.util.List<Term> getChildren()
Description copied from interface: Term
A list of terms which are the immediate children. If the term is a variable this return null; it is a constant this returns the empty list.

Specified by:
getChildren in interface Term

leadingOperationSymbol

public OperationSymbol leadingOperationSymbol()
Description copied from interface: Term
The leading operation symbol or null if this term is a variable.

Specified by:
leadingOperationSymbol in interface Term

eval

public java.lang.Object eval(Algebra alg,
                             java.util.Map map)
Description copied from interface: Term
The evaluation of this term in an algebra using map as the variable assignment.

Specified by:
eval in interface Term

intEval

public int intEval(Algebra alg,
                   java.util.Map map)
Description copied from interface: Term
The int evaluation of this term in an algebra using map as the variable assignment.

Specified by:
intEval in interface Term

interpretation

public Operation interpretation(SmallAlgebra alg,
                                java.util.List<Variable> varlist,
                                boolean all)
Description copied from interface: Term
The interpretation of this term in an algebra; that is, the operation on alg corresponding to this term. The varlist, a list of Variable's, specifies the order. If useAll is true, variables that are not explicit in this term are still used.
For example, suppose the term is (z*y)*z, and varlist is (x, y, z). If useAll is true, the resulting operation will have arity 3 and be independent of its first variable. Otherwise it will be a 2 place operation with y as the first variable and z as the second.

Specified by:
interpretation in interface Term
Parameters:
alg - the Algebra
varlist - the list of variables
all - if true, use all the variables in varlist
Returns:
the term operation

interpretation

public TermOperation interpretation(SmallAlgebra alg)
Description copied from interface: Term
The operation obtained from this term using the variables in the order they occur.
For example, suppose the term is (z*y)*z. The result will be a 2 place operation with z as the first variable and y as the second.

Specified by:
interpretation in interface Term
Parameters:
alg - the Algebra
Returns:
the term operation
See Also:
#interpretation(Algebra,List,boolean)

getVariableList

public java.util.List getVariableList()
Description copied from interface: Term
The list of variables in the order they appear in the term.

Specified by:
getVariableList in interface Term

depth

public int depth()
Description copied from interface: Term
The depth of the term tree. A variable has depth 0.

Specified by:
depth in interface Term

length

public int length()
Description copied from interface: Term
The length of the term. A variable has length 1.

Specified by:
length in interface Term

substitute

public Term substitute(java.util.Map<Variable,Term> map)
Description copied from interface: Term
Replace some of the variables with terms.

Specified by:
substitute in interface Term
Parameters:
map - a map for the substitution
Returns:

toString

public java.lang.String toString()
Description copied from interface: Term
A reasonably good printout of the term.

Specified by:
toString in interface Term
Overrides:
toString in class java.lang.Object

writeStringBuffer

public java.lang.StringBuffer writeStringBuffer(java.lang.StringBuffer sb)
Description copied from interface: Term
This is really an efficiency helper for toString. It returns the StringBuffer as a convenience.

Specified by:
writeStringBuffer in interface Term


Copyright 2003 Ralph Freese. All Rights Reserved.