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 StandardParser 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
ConstructorsConstructorDescriptionCreate a medium weight instance with copies of all variablesMediumWeightComponentSet(Jep jep, boolean copyConstants) Create a medium weight instance either with an empty variable table or one with just the constants.MediumWeightComponentSet(Jep baseJep, JepComponent... replacements) Create a medium weight instance where replacements are used in preference to the base Jep. -
Method Summary
Methods inherited from class com.singularsys.jep.ComponentSet
addAuxComponent, addComponents, findOrElse, 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 medium weight instance with copies of all variables -
MediumWeightComponentSet
Create a medium weight instance either with an empty variable table or one with just the constants.- Parameters:
jep- the source to copy components fromcopyConstants- if true copy the constants, if false leave empty
-
MediumWeightComponentSet
Create a medium weight instance where replacements are used in preference to the base Jep.- Parameters:
baseJep- the source to copy components fromreplacements- components to replace
-