public class TreeAnalyzer extends PostfixTreeWalker
Constructor and Description |
---|
TreeAnalyzer()
Creates an empty tree analyser.
|
TreeAnalyzer(Node node)
Create a new instance and Analyze the node.
|
Modifier and Type | Method and Description |
---|---|
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
|
supressExaminingChildren, walk, walkSubEquations
public TreeAnalyzer(Node node) throws JepException
node
- node to analyzeJepException
public TreeAnalyzer()
merge(TreeAnalyzer)
method.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
- Copyright © 2018 Singular Systems http://www.singularsys.com/jep