|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.singularsys.jep.walkers.PostfixTreeWalker com.singularsys.jep.walkers.TreeAnalyzer
public class TreeAnalyzer
Analyze an expression, counting the number of nodes of each type, and recording which variables, functions and operators occurred in the expression.
Constructor Summary | |
---|---|
TreeAnalyzer()
Creates an empty tree analyser. |
|
TreeAnalyzer(Node node)
Create a new instance and Analyze the node. |
Method Summary | |
---|---|
void |
analyze(Node node)
Analyze a node, results will be added to the current total. |
java.util.Map<java.lang.Object,java.lang.Integer> |
getConstants()
A map with each constant and the number of times it occurs |
java.util.Map<java.lang.String,java.lang.Integer> |
getFunctions()
A map with each function used and the number of times it occurred |
int |
getMaxDepth()
The depth of the tree |
int |
getNumConst()
|
int |
getNumFunctions()
|
int |
getNumNodes()
|
int |
getNumOperators()
|
int |
getNumUniqueVariables()
|
int |
getNumVariables()
|
java.util.Map<Operator,java.lang.Integer> |
getOperators()
A map with each operator used and the number of times it occurred |
java.lang.String[] |
getVariableNames()
Return the names of the variables, sorted alphabetically. |
java.util.Map<Variable,java.lang.Integer> |
getVariables()
A map with each variable used and the number of times it occurred |
void |
merge(TreeAnalyzer ta)
Merge the result with the argument, producing total for all trees. |
java.lang.String |
summary()
A short summary string |
java.lang.String |
toString()
Reports statistics about the tree, number of nodes, depth, and the number of varibles, functions, operators and constants with the number of times each occurs. |
protected void |
visit(ASTConstant node,
int nchildren,
int depth)
Visit a constant node |
protected void |
visit(ASTFunNode node,
int nchildren,
int depth)
Visit a function node |
protected void |
visit(ASTOpNode node,
int nchildren,
int depth)
Visit an operator node |
protected void |
visit(ASTVarNode node,
int nchildren,
int depth)
Visit a variable node |
Methods inherited from class com.singularsys.jep.walkers.PostfixTreeWalker |
---|
supressExaminingChildren, walk, walkSubEquations |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public TreeAnalyzer(Node node) throws JepException
node
- node to analyze
JepException
public TreeAnalyzer()
merge(TreeAnalyzer)
method.
Method Detail |
---|
public void analyze(Node node) throws JepException
node
-
JepException
public java.lang.String toString()
toString
in class java.lang.Object
public java.lang.String summary()
protected void visit(ASTFunNode node, int nchildren, int depth)
PostfixTreeWalker
visit
in class PostfixTreeWalker
node
- the current node being visitednchildren
- number of children of the nodedepth
- depth of tree, root node is depth 1.protected void visit(ASTOpNode node, int nchildren, int depth)
PostfixTreeWalker
visit
in class PostfixTreeWalker
node
- the current node being visitednchildren
- number of children of the nodedepth
- depth of tree, root node is depth 1.protected void visit(ASTVarNode node, int nchildren, int depth)
PostfixTreeWalker
visit
in class PostfixTreeWalker
node
- the current node being visitednchildren
- number of children of the nodedepth
- depth of tree, root node is depth 1.protected void visit(ASTConstant node, int nchildren, int depth)
PostfixTreeWalker
visit
in class PostfixTreeWalker
node
- the current node being visitednchildren
- number of children of the nodedepth
- depth of tree, root node is depth 1.public int getMaxDepth()
public int getNumConst()
public int getNumFunctions()
public int getNumNodes()
public int getNumOperators()
public int getNumVariables()
public int getNumUniqueVariables()
public java.util.Map<Operator,java.lang.Integer> getOperators()
public java.util.Map<Variable,java.lang.Integer> getVariables()
public java.lang.String[] getVariableNames()
public java.util.Map<java.lang.String,java.lang.Integer> getFunctions()
public java.util.Map<java.lang.Object,java.lang.Integer> getConstants()
public void merge(TreeAnalyzer ta)
ta
-
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |