Package org.jacop.jasat.utils
Class MemoryPool
java.lang.Object
org.jacop.jasat.utils.MemoryPool
- All Implemented Interfaces:
SolverComponent
Class containing int[] of different lengths, to avoid allocating/deallocating too much.
- Version:
- 4.10
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionint[]getNew(int size) returns an array, from the pool if one is available, allocating it otherwisevoidinitialize(Core core) initializes the component with the given solver.private voidsetupPool(int maxSize, int stockSize) voidstoreOld(int[] array) save this array for a future usage, when not needed anymoretoString()
-
Field Details
-
pool
public int[][][] pool -
indexes
public int[] indexes -
stockSize
private int stockSize
-
-
Constructor Details
-
MemoryPool
public MemoryPool()
-
-
Method Details
-
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
-
initialize
Description copied from interface:SolverComponentinitializes 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:
initializein interfaceSolverComponent- Parameters:
core- core component to initialize
-