public interface NodeCalc
The writeJson method is used to serialize the tree to json.
The accept, acceptIterate and acceptHandle methods together with the
NodeCalcVisitor
interface form the
hybrid recursive/iterative visitor pattern. This visitor pattern
uses recursion on the children up to a stack depth limit because
performance is almost 5 times better when using recursion compared
to the iterative algorithm using stacks, but excessive depths cause
StackOverflowErrors.
The accept method are the main entrypoint of the hybrid visit and implements the recursive visit as well as performing the switch from the recursive to iterative behavior.
The acceptIterate and acceptHandle methods are used by NodeCalcVisitors
during the iterative traversal of the tree. The
acceptIterate method push children nodes the be traversed in the
stack. The acceptHandle method extract the already calculated
children results from the stack and use them to compute and return
the result for this node.
Modifier and Type | Method and Description |
---|---|
<R,A> R |
accept(NodeCalcVisitor<R,A> visitor,
A arg,
int depth) |
<R,A> R |
acceptHandle(NodeCalcVisitor<R,A> visitor,
A arg,
java.util.Deque<java.lang.Object> resultsStack) |
<R,A> void |
acceptIterate(NodeCalcVisitor<R,A> visitor,
A arg,
java.util.Deque<java.lang.Object> nodesStack) |
static TimeSeriesException |
createUnexpectedToken(com.fasterxml.jackson.core.JsonToken token) |
static NodeCalc |
parseJson(com.fasterxml.jackson.core.JsonParser parser) |
static NodeCalc |
parseJson(com.fasterxml.jackson.core.JsonParser parser,
com.fasterxml.jackson.core.JsonToken token) |
static NodeCalc |
parseJson(java.lang.String json) |
static java.lang.String |
toJson(NodeCalc node) |
void |
writeJson(com.fasterxml.jackson.core.JsonGenerator generator) |
static void |
writeJson(NodeCalc node,
com.fasterxml.jackson.core.JsonGenerator generator) |
<R,A> R accept(NodeCalcVisitor<R,A> visitor, A arg, int depth)
<R,A> void acceptIterate(NodeCalcVisitor<R,A> visitor, A arg, java.util.Deque<java.lang.Object> nodesStack)
<R,A> R acceptHandle(NodeCalcVisitor<R,A> visitor, A arg, java.util.Deque<java.lang.Object> resultsStack)
void writeJson(com.fasterxml.jackson.core.JsonGenerator generator) throws java.io.IOException
java.io.IOException
static void writeJson(NodeCalc node, com.fasterxml.jackson.core.JsonGenerator generator)
static java.lang.String toJson(NodeCalc node)
static NodeCalc parseJson(java.lang.String json)
static NodeCalc parseJson(com.fasterxml.jackson.core.JsonParser parser)
static TimeSeriesException createUnexpectedToken(com.fasterxml.jackson.core.JsonToken token)
static NodeCalc parseJson(com.fasterxml.jackson.core.JsonParser parser, com.fasterxml.jackson.core.JsonToken token) throws java.io.IOException
java.io.IOException
Copyright © 2020. All rights reserved.