Class MediumWeightComponentSet

java.lang.Object
com.singularsys.jep.ComponentSet
com.singularsys.jep.misc.MediumWeightComponentSet

public class MediumWeightComponentSet extends ComponentSet

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:
  • Constructor Details

    • MediumWeightComponentSet

      public MediumWeightComponentSet(Jep jep)
      Create a lightweight instance with copies of all variables
    • MediumWeightComponentSet

      public MediumWeightComponentSet(Jep jep, boolean copyConstants)
      Create a lightweight instance either with an empty variable table or one with just the constants.
      Parameters:
      jep - the source instance
      copyConstants - if true copy the constants, if false leave empty