|
|||||||||
| Home >> All >> org >> maloi >> evolvo >> [ expressiontree overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
org.maloi.evolvo.expressiontree
Class ExpressionTree

java.lang.Objectorg.maloi.evolvo.expressiontree.ExpressionTree
- All Implemented Interfaces:
- java.io.Serializable
- public class ExpressionTree
- extends java.lang.Object
- implements java.io.Serializable
- extends java.lang.Object
Handles mathematic expressions in a tree structure, including storage, evaluation, and display. Will eventually provide the functionality to manipulate the tree as well.
| Field Summary | |
(package private) boolean |
cacheable
|
(package private) double |
cachedValue
Holds the cached value for this branch. |
(package private) org.maloi.evolvo.expressiontree.operators.OperatorInterface |
operator
Holds the operator for this node of the tree. |
(package private) ExpressionTree[] |
params
Holds parameters to this node's operator. |
(package private) static org.maloi.evolvo.expressiontree.utilities.VariablePackage |
vp
With the new expression evaluation engine, there's no need to keep passing a variablePackage around, so we'll just keep one instance of it here. |
| Constructor Summary | |
ExpressionTree()
Creates a new expressionTree |
|
ExpressionTree(ExpressionTree[] prms,
org.maloi.evolvo.expressiontree.operators.OperatorInterface op)
Creates a new expressionTree with operator op and parameters prms[] |
|
| Method Summary | |
void |
buildMachine(org.maloi.evolvo.expressiontree.vm.Machine myMachine)
|
ExpressionTree |
getClone()
Convenience method to retrieve a clone of expressionTree as type expressionTree. |
org.maloi.evolvo.expressiontree.vm.Machine |
getMachine()
Builds a simple stack machine to evaluate this expression. |
java.lang.String |
getName()
Returns the name of this node's operator. |
int |
getNumParams()
Returns the number of parameters this node expects. |
org.maloi.evolvo.expressiontree.operators.OperatorInterface |
getOperator()
Returns the operator this node holds. |
int |
getParamLength()
Returns the number of parameter's this node's operator expects. |
ExpressionTree[] |
getParams()
Returns the parameters this node is holding. |
void |
setOperator(org.maloi.evolvo.expressiontree.operators.OperatorInterface o)
Sets this node's operator. |
void |
setParams(ExpressionTree[] p)
Set this node's parameters. |
java.lang.String |
toString()
Returns a (sort of) human readable string representation of the expression. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
params
ExpressionTree[] params
- Holds parameters to this node's operator.
operator
org.maloi.evolvo.expressiontree.operators.OperatorInterface operator
- Holds the operator for this node of the tree.
cachedValue
double cachedValue
- Holds the cached value for this branch.
cacheable
boolean cacheable
vp
static org.maloi.evolvo.expressiontree.utilities.VariablePackage vp
- With the new expression evaluation engine, there's no need
to keep passing a variablePackage around, so we'll just
keep one instance of it here.
TODO: Make variablePackage static
| Constructor Detail |
ExpressionTree
public ExpressionTree()
- Creates a new expressionTree
ExpressionTree
public ExpressionTree(ExpressionTree[] prms, org.maloi.evolvo.expressiontree.operators.OperatorInterface op)
- Creates a new expressionTree with operator op and parameters prms[]
| Method Detail |
getClone
public ExpressionTree getClone()
- Convenience method to retrieve a clone of expressionTree as type
expressionTree.
toString
public java.lang.String toString()
- Returns a (sort of) human readable string representation of the
expression.
The resulting string contains the expression written in a lisp-like
notation. For example, the simple equation "1+1" would be written as
"(+ 1 1)".
getName
public java.lang.String getName()
- Returns the name of this node's operator.
getParamLength
public int getParamLength()
- Returns the number of parameter's this node's operator expects.
setParams
public void setParams(ExpressionTree[] p)
- Set this node's parameters.
Note: Currently does not check that p[] has the correct number of
elements. If p[] has too many elements, the extras are simply thrown
out.
If, however, there are too few, the results are unpredicatable.
This behavior should be modified in future versions to be more robust.
getNumParams
public int getNumParams()
- Returns the number of parameters this node expects.
getParams
public ExpressionTree[] getParams()
- Returns the parameters this node is holding.
getOperator
public org.maloi.evolvo.expressiontree.operators.OperatorInterface getOperator()
- Returns the operator this node holds.
setOperator
public void setOperator(org.maloi.evolvo.expressiontree.operators.OperatorInterface o)
- Sets this node's operator.
Note: If the new operator expects more parameters than
the current operator, results are unpredicatable.
This behaviour should be modified in future version to be more robust.
getMachine
public org.maloi.evolvo.expressiontree.vm.Machine getMachine()
- Builds a simple stack machine to evaluate this expression.
Simply creates a new machine and passes it on to
the buildMachine(machine) method.
buildMachine
public void buildMachine(org.maloi.evolvo.expressiontree.vm.Machine myMachine)
|
|||||||||
| Home >> All >> org >> maloi >> evolvo >> [ expressiontree overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
JAVADOC
org.maloi.evolvo.expressiontree.ExpressionTree