Package redempt.crunch
Class CompiledExpression
java.lang.Object
redempt.crunch.CompiledExpression
An expression which has been compiled with
Crunch.compileExpression(String) and can be evaluated with evaluate(double...)-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionclone()doubleevaluate()Evaluates this CompiledExpression and returns its value without modifying variable valuesdoubleevaluate(double first) Evaluates this CompiledExpression and returns its valuedoubleevaluate(double... values) Evaluates this CompiledExpression and returns its valuedoubleevaluate(double first, double second) Evaluates this CompiledExpression and returns its valuegetValue()Gets the internal Value representation of the expression.intGets the highest index of variables used in this expression.protected voidinitialize(Value value, int variableCount) protected voidsetVariableValues(double[] values) toString()Converts this CompiledExpression back to a String which can be used to recreate it later
-
Field Details
-
variableValues
protected double[] variableValues
-
-
Constructor Details
-
CompiledExpression
protected CompiledExpression() -
CompiledExpression
-
-
Method Details
-
initialize
-
setVariableValues
protected void setVariableValues(double[] values) -
getValue
Gets the internal Value representation of the expression. This is essentially reflection into the expression. Proceed at your own risk.- Returns:
- The Value this CompiledExpression wraps
-
getVariableCount
public int getVariableCount()Gets the highest index of variables used in this expression. Any call toevaluate(double...)must pass at least this many values.- Returns:
- The number of variables used in this expression
-
evaluate
public double evaluate(double... values) Evaluates this CompiledExpression and returns its value- Parameters:
values- The values for variables used in this expression, in order starting with 1- Returns:
- The resulting value
-
evaluate
public double evaluate()Evaluates this CompiledExpression and returns its value without modifying variable values- Returns:
- The resulting value
-
evaluate
public double evaluate(double first) Evaluates this CompiledExpression and returns its value- Parameters:
first- The first variable value- Returns:
- The resulting value
-
evaluate
public double evaluate(double first, double second) Evaluates this CompiledExpression and returns its value- Parameters:
first- The first variable valuesecond- The second variable value- Returns:
- The resulting value
-
clone
-
toString
Converts this CompiledExpression back to a String which can be used to recreate it later
-