Class MediumWeightComponentSet
A medium weight set of components reusing components from an existing Jep instance.
This class will reuse the
NumberFactory, VariableFactory, and PrintVisitor components of the supplied Jep.
The FunctionTable and OperatorTable will use their respective shallowCopy()
methods. These will copy most functions or operators except when the PFMC implements
JepComponent
indicating it is not thread safe. In that case the functions
getLightWeightInstance()
will be called to create a thread safe version.
It will have a NullParser so it can not be used for parsing expressions.
New copies of the VariableTable, StandardEvaluator and NodeFactory
are used. The VariableTable will be filled with the copies of the variables
in the supplied instances' variable table.
To construct a medium weight jep instance use
Jep j = new Jep(); MediumWeightComponentSet mwcs = new MediumWeightComponentSet(j); Jep j2 = new Jep(mwcs);
Such instance typically use 4kB compared to 1kB for the lightWeightComponentSet, 56kB bytes for a Jep instance with a StandardConfigurableParser and 14kB bytes with a configurable parser.
Jep j = new Jep(); MediumWeightComponentSet lwcs = new LightWeightComponentSet(j); FunctionTable ft = lwcs.getFunctionTable().shallowCopy(); // use new instances of the pfmc's lwcs.setFunctionTable(ft);
As of Jep version 3.5 the LightWeightComponentSet uses a Null Print Visitor so cannot print.
- See Also:
-
Field Summary
-
Constructor Summary
ConstructorDescriptionCreate a lightweight instance with copies of all variablesMediumWeightComponentSet
(Jep jep, boolean copyConstants) Create a lightweight instance either with an empty variable table or one with just the constants. -
Method Summary
Methods inherited from class com.singularsys.jep.ComponentSet
addAuxComponent, addComponents, getAuxComponents, getAuxComps, getBaseComponents, getComponents, getEvaluator, getFunctionTable, getNodeFactory, getNumberFactory, getOperatorTable, getParser, getPrintVisitor, getVariableFactory, getVariableTable, setAuxComps, setEvaluator, setFunctionTable, setNodeFactory, setNumberFactory, setOperatorTable, setParser, setPrintVisitor, setVariableFactory, setVariableTable
-
Constructor Details
-
MediumWeightComponentSet
Create a lightweight instance with copies of all variables -
MediumWeightComponentSet
Create a lightweight instance either with an empty variable table or one with just the constants.- Parameters:
jep
- the source instancecopyConstants
- if true copy the constants, if false leave empty
-