Package com.singularsys.jep.misc

# 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 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:
  - `LightWeightComponentSet`

- ## Field Summary

  ### Fields inherited from class com.singularsys.jep.ComponentSet

  `auxComps, evaluator, funTab, nodeFac, numFac, opTab, parser, pv, varFac, varTab`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `MediumWeightComponentSet(Jep jep)`
  Create a medium weight instance with copies of all variables
  `MediumWeightComponentSet(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`

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Constructor Details

  - ### MediumWeightComponentSet

    public MediumWeightComponentSet(Jep jep)
    Create a medium weight instance with copies of all variables

  - ### MediumWeightComponentSet

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

  - ### MediumWeightComponentSet

    public MediumWeightComponentSet(Jep baseJep, JepComponent... replacements)
    Create a medium weight instance where replacements are used in preference to the base Jep.
    Parameters:
      `baseJep` - the source to copy components from
      `replacements` - components to replace