com.singularsys.jep.misc

## Class LightWeightComponentSet

- java.lang.Object
- - com.singularsys.jep.ComponentSet
  - - com.singularsys.jep.misc.LightWeightComponentSet

-     public class LightWeightComponentSet
      extends ComponentSet

  A lightweight set of components reusing components from an existing Jep instance. This class will reuse the NumberFactory, VariableFactory, FunctionTable, OperatorTable, and PrintVisitor components of the supplied Jep. 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 lightweight jep instance use

       Jep j = new Jep();
       LightWeightComponentSet lwcs = new LightWeightComponentSet(j);
       Jep j2 = new Jep(lwcs);

  Such instance typically use 1kB compared to 56kB bytes for a Jep instance with a StandardParser and 14kB bytes with a configurable parser.

  As this reuses the function table and PostfixMathCommands in it. There may be cases where the pfmc are not optimized for use in multiple threads `Random` is the only example of this. While safe to use in multiple threads efficiency is improved if each thread has its own copy. If this is an issue the shallowCopy() methods of function table can be used.

       Jep j = new Jep();
       LightWeightComponentSet 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.

- - ### Field Summary

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

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

  - ### Constructor Summary

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

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

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

- - ### Constructor Detail

    - #### LightWeightComponentSet

          public LightWeightComponentSet(Jep jep)

      Create a lightweight instance with copies of all variables

    - #### LightWeightComponentSet

          public LightWeightComponentSet(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

Copyright © 2018 Singular Systems http://www.singularsys.com/jep