Package com.singularsys.jep.walkers
Expression tree traversal classes.
These classes implement various methods of traversing trees representing equations.
For very large equations with 10,000+ nodes the standard ParserVisitor
class
can encounter problems with stack overflows due to recursions. The PostfixTreeWalker
offers a base class for
a traversal strategy which minimises the number of stack frames
used and the PostfixEvaluator
is an evaluator which uses this strategy. These methods visit each node in postfix fashion
hence for 1+cos(x)
the nodes are visited in the order
1, x, cos, +
.
PrefixTreeWalker
is similar but visits nodes in a prefix fashion
for 1+cos(x)
the nodes are visited in the order
+, 1, cos, x
.
DoNothingVisitor
and DeepCopyVisitor
are two base classes for classes which manipulate
expressions using a standard recursive traversal. DoNothingVisitor
visits each node
in turn performing no action and returning the node.
DeepCopyVisitor
visits each node returning a copy of that node.
-
Interface Summary Interface Description SerializableExpression.Element interface used in internal representation of expression -
Class Summary Class Description DeepCopyVisitor A Visitor which returns an exact copy of the tree.DoNothingVisitor A Visitor which visits each node of a expression tree and does nothing.ExpressionConsolidator Consolidates nested addition and multiplication to produce nary operators.HookRemover Remove a specific hook from a any node which has it on a treeImportationVisitor Imports an expression from one Jep instance into another.PostfixEvaluator Evaluation component that avoids excessive use of the stack for large expressions.PostfixTreeWalker Base class for routines which use a non recursive tree walker strategy.PrefixTreeDumper Dumps the contents of a tree to a specified stream, or to standard output.PrefixTreeWalker Base class for routines which use a non recursive tree walker strategy.SerializableExpression A serializable representation of an expression.SerializableExpression.Constant SerializableExpression.Function SerializableExpression.Operator SerializableExpression.Variable SubstitutionVisitor Allows substitution of variable with values or expressions.TreeAnalyzer Analyze an expression, counting the number of nodes of each type, and recording which variables, functions and operators occurred in the expression.