Class VariablePool


  • public class VariablePool
    extends java.lang.Object
    Utility class for caching / pooling variables in order to save memory. Please use this class local to a model / operation in order avoid that memory remains allocated although not used.
    Author:
    Sascha El-Sharkawy, Holger Eichelberger
    • Field Detail

      • variablesCache

        private java.util.Map<java.lang.Integer,​Variable> variablesCache
    • Constructor Detail

      • VariablePool

        public VariablePool()
    • Method Detail

      • keyObject

        public static final java.lang.Integer keyObject​(AbstractVariable decl)
        Returns the key object for hashes, also for tests. This is needed, as the equals/hashcode implementation of AbstractVariable is just based on the name and does not cope with local variables. This method shall remind dependent implementations about the aforementionied problem.
        Parameters:
        decl - the declaration
        Returns:
        the key/hash object
      • knowsVariable

        public final boolean knowsVariable​(AbstractVariable decl)
        Returns whether this pool knows a certain variable.
        Parameters:
        decl - the variable declaration
        Returns:
        true if the pool knows the variable, false else
      • clear

        public final void clear()
        Clears this pool for reuse or to force unallocation of memory.
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object