Class MemoryPool

  • All Implemented Interfaces:
    SolverComponent

    public final class MemoryPool
    extends java.lang.Object
    implements SolverComponent
    Class containing int[] of different lengths, to avoid allocating/deallocating too much.
    Version:
    4.7
    • Field Summary

      Fields 
      Modifier and Type Field Description
      int[] indexes  
      int[][][] pool  
      private int stockSize  
    • Constructor Summary

      Constructors 
      Constructor Description
      MemoryPool()  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      int[] getNew​(int size)
      returns an array, from the pool if one is available, allocating it otherwise
      void initialize​(Core core)
      initializes the component with the given solver.
      private void setupPool​(int maxSize, int stockSize)  
      void storeOld​(int[] array)
      save this array for a future usage, when not needed anymore
      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Field Detail

      • pool

        public int[][][] pool
      • indexes

        public int[] indexes
      • stockSize

        private int stockSize
    • Constructor Detail

      • MemoryPool

        public MemoryPool()
    • Method Detail

      • getNew

        public int[] getNew​(int size)
        returns an array, from the pool if one is available, allocating it otherwise
        Parameters:
        size - the size of the array we need
        Returns:
        an int[size] array
      • storeOld

        public void storeOld​(int[] array)
        save this array for a future usage, when not needed anymore
        Parameters:
        array - the array to store
      • setupPool

        private void setupPool​(int maxSize,
                               int stockSize)
      • toString

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

        public void initialize​(Core core)
        Description copied from interface: SolverComponent
        initializes the component with the given solver. May be called only once. This method must register the component to the solver for the run.
        Specified by:
        initialize in interface SolverComponent
        Parameters:
        core - core component to initialize