A node of an expression tree that represents a function. More...
Public Member Functions | |
FuncNode (String name, boolean negate) | |
void | add (Expression x) |
Adds the expression as a child. | |
void | insert (Expression x, int i) |
Adds the expression as a child at the specified index. | |
void | remove (Expression x) |
Removes the specified expression as a child. | |
int | numChildren () |
Returns the number of child expressions. | |
Expression | child (int i) |
Returns the child expression at the specified index. | |
double | eval (VarMap v, FuncMap f) |
Evaluates each of the children, storing the result in an internal double array. | |
boolean | getNegate () |
Returns true if the term should negate the result before returning it in the eval method. | |
void | setNegate (boolean b) |
String | getName () |
Returns the name of the term. | |
void | setName (String s) |
Sets the name of the term. | |
boolean | isDescendent (Expression x) |
Returns true if this node is a descendent of the specified node, false otherwise. | |
Expression | getParent () |
Returns the parent of this node. | |
String[] | getVariableNames () |
Returns an array of exact length of the variable names contained in the expression tree rooted at this node. | |
String[] | getFunctionNames () |
Returns an array of exact length of the function names contained in the expression tree rooted at this node. | |
String | toString () |
Returns a string that represents the expression tree rooted at this node. | |
Protected Member Functions | |
void | checkBeforeAccept (Expression x) |
Protected method used to verify that the specified expression can be included as a child expression of this node. | |
Protected Attributes | |
String | name = null |
boolean | negate = false |
Expression | parent = null |
Private Attributes | |
Bag | bag = new Bag(1) |
double[] | of = new double[1] |
A node of an expression tree that represents a function.
A FuncNode can have 0 or more children.
Definition at line 8 of file FuncNode.java.
com.graphbuilder.math.FuncNode.FuncNode | ( | String | name, | |
boolean | negate | |||
) |
Definition at line 13 of file FuncNode.java.
void com.graphbuilder.math.FuncNode.add | ( | Expression | x | ) |
Adds the expression as a child.
Definition at line 20 of file FuncNode.java.
References com.graphbuilder.math.FuncNode.bag, com.graphbuilder.math.FuncNode.insert(), and com.graphbuilder.struc.Bag.size.
Referenced by com.graphbuilder.math.ExpressionTree.build().
void com.graphbuilder.math.Expression.checkBeforeAccept | ( | Expression | x | ) | [protected, inherited] |
Protected method used to verify that the specified expression can be included as a child expression of this node.
IllegalArgumentException | If the specified expression is not accepted. |
Definition at line 51 of file Expression.java.
References com.graphbuilder.math.Expression.isDescendent(), and com.graphbuilder.math.Expression.parent.
Referenced by com.graphbuilder.math.FuncNode.insert(), com.graphbuilder.math.OpNode.setLeftChild(), and com.graphbuilder.math.OpNode.setRightChild().
Expression com.graphbuilder.math.FuncNode.child | ( | int | i | ) |
Returns the child expression at the specified index.
Definition at line 59 of file FuncNode.java.
References com.graphbuilder.math.FuncNode.bag, and com.graphbuilder.struc.Bag.get().
Referenced by com.graphbuilder.math.FuncNode.eval(), com.graphbuilder.math.Expression.getTermNames(), and com.graphbuilder.math.Expression.toString().
Evaluates each of the children, storing the result in an internal double array.
The FuncMap is used to obtain a Function object based on the name of this FuncNode. The function is passed the double array and returns a result. If negate is true, the result is negated. The result is then returned. The numParam passed to the function is the number of children of this FuncNode.
Implements com.graphbuilder.math.Expression.
Definition at line 69 of file FuncNode.java.
References com.graphbuilder.math.FuncNode.bag, com.graphbuilder.math.FuncNode.child(), com.graphbuilder.math.Expression.eval(), com.graphbuilder.math.FuncMap.getFunction(), com.graphbuilder.math.TermNode.name, com.graphbuilder.math.TermNode.negate, com.graphbuilder.math.FuncNode.of, and com.graphbuilder.struc.Bag.size.
String [] com.graphbuilder.math.Expression.getFunctionNames | ( | ) | [inherited] |
Returns an array of exact length of the function names contained in the expression tree rooted at this node.
Definition at line 72 of file Expression.java.
References com.graphbuilder.math.Expression.getTermNames().
String com.graphbuilder.math.TermNode.getName | ( | ) | [inherited] |
Returns the name of the term.
Definition at line 30 of file TermNode.java.
References com.graphbuilder.math.TermNode.name.
Referenced by com.graphbuilder.math.Expression.toString().
boolean com.graphbuilder.math.TermNode.getNegate | ( | ) | [inherited] |
Returns true if the term should negate the result before returning it in the eval method.
Definition at line 19 of file TermNode.java.
References com.graphbuilder.math.TermNode.negate.
Referenced by com.graphbuilder.math.Expression.toString().
Expression com.graphbuilder.math.Expression.getParent | ( | ) | [inherited] |
Returns the parent of this node.
Definition at line 41 of file Expression.java.
References com.graphbuilder.math.Expression.parent.
String [] com.graphbuilder.math.Expression.getVariableNames | ( | ) | [inherited] |
Returns an array of exact length of the variable names contained in the expression tree rooted at this node.
Definition at line 65 of file Expression.java.
References com.graphbuilder.math.Expression.getTermNames().
void com.graphbuilder.math.FuncNode.insert | ( | Expression | x, | |
int | i | |||
) |
Adds the expression as a child at the specified index.
Definition at line 27 of file FuncNode.java.
References com.graphbuilder.math.FuncNode.bag, com.graphbuilder.math.Expression.checkBeforeAccept(), com.graphbuilder.struc.Bag.getCapacity(), com.graphbuilder.struc.Bag.insert(), com.graphbuilder.math.FuncNode.of, and com.graphbuilder.math.Expression.parent.
Referenced by com.graphbuilder.math.FuncNode.add().
boolean com.graphbuilder.math.Expression.isDescendent | ( | Expression | x | ) | [inherited] |
Returns true if this node is a descendent of the specified node, false otherwise.
By this methods definition, a node is a descendent of itself.
Definition at line 26 of file Expression.java.
References com.graphbuilder.math.Expression.parent.
Referenced by com.graphbuilder.math.Expression.checkBeforeAccept().
int com.graphbuilder.math.FuncNode.numChildren | ( | ) |
Returns the number of child expressions.
Definition at line 52 of file FuncNode.java.
References com.graphbuilder.math.FuncNode.bag, and com.graphbuilder.struc.Bag.size.
Referenced by com.graphbuilder.math.ExpressionTree.build(), com.graphbuilder.math.Expression.getTermNames(), and com.graphbuilder.math.Expression.toString().
void com.graphbuilder.math.FuncNode.remove | ( | Expression | x | ) |
Removes the specified expression as a child.
Does nothing if the expression was not a child.
Definition at line 42 of file FuncNode.java.
References com.graphbuilder.math.FuncNode.bag, com.graphbuilder.struc.Bag.remove(), and com.graphbuilder.struc.Bag.size.
void com.graphbuilder.math.TermNode.setName | ( | String | s | ) | [inherited] |
Sets the name of the term.
Valid names must not begin with a digit or a decimal, and must not contain round brackets, operators, commas or whitespace.
IllegalArgumentException | If the name is null or invalid. |
Definition at line 40 of file TermNode.java.
References com.graphbuilder.math.TermNode.isValidName(), and com.graphbuilder.math.TermNode.name.
Referenced by com.graphbuilder.math.TermNode.TermNode().
void com.graphbuilder.math.TermNode.setNegate | ( | boolean | b | ) | [inherited] |
Definition at line 23 of file TermNode.java.
References com.graphbuilder.math.TermNode.negate.
Referenced by com.graphbuilder.math.TermNode.TermNode().
String com.graphbuilder.math.Expression.toString | ( | ) | [inherited] |
Returns a string that represents the expression tree rooted at this node.
Definition at line 114 of file Expression.java.
Referenced by edu.rice.cs.hpc.viewer.metric.ExtDerivedMetricDlg.createDialogArea(), and com.graphbuilder.math.Expression.toString().
Bag com.graphbuilder.math.FuncNode.bag = new Bag(1) [private] |
Definition at line 10 of file FuncNode.java.
Referenced by com.graphbuilder.math.FuncNode.add(), com.graphbuilder.math.FuncNode.child(), com.graphbuilder.math.FuncNode.eval(), com.graphbuilder.math.FuncNode.insert(), com.graphbuilder.math.FuncNode.numChildren(), and com.graphbuilder.math.FuncNode.remove().
String com.graphbuilder.math.TermNode.name = null [protected, inherited] |
Definition at line 8 of file TermNode.java.
Referenced by com.graphbuilder.math.VarNode.eval(), com.graphbuilder.math.FuncNode.eval(), com.graphbuilder.math.TermNode.getName(), com.graphbuilder.math.Expression.getTermNames(), and com.graphbuilder.math.TermNode.setName().
boolean com.graphbuilder.math.TermNode.negate = false [protected, inherited] |
Definition at line 9 of file TermNode.java.
Referenced by com.graphbuilder.math.VarNode.eval(), com.graphbuilder.math.FuncNode.eval(), com.graphbuilder.math.TermNode.getNegate(), and com.graphbuilder.math.TermNode.setNegate().
double [] com.graphbuilder.math.FuncNode.of = new double[1] [private] |
Definition at line 11 of file FuncNode.java.
Referenced by com.graphbuilder.math.FuncNode.eval(), and com.graphbuilder.math.FuncNode.insert().
Expression com.graphbuilder.math.Expression.parent = null [protected, inherited] |
Definition at line 15 of file Expression.java.
Referenced by com.graphbuilder.math.Expression.checkBeforeAccept(), com.graphbuilder.math.Expression.getParent(), com.graphbuilder.math.FuncNode.insert(), com.graphbuilder.math.Expression.isDescendent(), com.graphbuilder.math.OpNode.setLeftChild(), and com.graphbuilder.math.OpNode.setRightChild().