Class ArrayCache
- java.lang.Object
-
- de.gsi.dataset.utils.ArrayCache
-
public final class ArrayCache extends java.lang.ObjectSimple cache for large recurring primitive arrays, e.g. to be used in functions where often large temporary arrays are needed but that are otherwise outside the function scope not needed. usage example:private final static String UNIQUE_IDENTIFIER = "class/app unique name"; [..] final double[] localTempBuffer = ArrayCache.getCachedDoubleArray(UNIQUE_IDENTIFIER, 200); [..] user code [..] ArrayCache.release(UNIQUE_IDENTIFIER, 100);
N.B. for other simple caching needs see @see Cache- Author:
- rstein
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static boolean[]getCachedBooleanArray(java.lang.String arrayName, int size)Returns cached large recurring primitive arrays, e.g.static byte[]getCachedByteArray(java.lang.String arrayName, int size)Returns cached large recurring primitive arrays, e.g.static double[]getCachedDoubleArray(java.lang.String arrayName, int size)Returns cached large recurring primitive arrays, e.g.static float[]getCachedFloatArray(java.lang.String arrayName, int size)Returns cached large recurring primitive arrays, e.g.static int[]getCachedIntArray(java.lang.String arrayName, int size)Returns cached large recurring primitive arrays, e.g.static long[]getCachedLongArray(java.lang.String arrayName, int size)Returns cached large recurring primitive arrays, e.g.static short[]getCachedShortArray(java.lang.String arrayName, int size)Returns cached large recurring primitive arrays, e.g.static java.lang.String[]getCachedStringArray(java.lang.String arrayName, int size)Returns cached large recurring primitive arrays, e.g.static voidrelease(java.lang.String arrayName, boolean[] cachedArray)Returns ownership of array to cachestatic voidrelease(java.lang.String arrayName, byte[] cachedArray)Returns ownership of array to cachestatic voidrelease(java.lang.String arrayName, double[] cachedArray)Returns ownership of array to cachestatic voidrelease(java.lang.String arrayName, float[] cachedArray)Returns ownership of array to cachestatic voidrelease(java.lang.String arrayName, int[] cachedArray)Returns ownership of array to cachestatic voidrelease(java.lang.String arrayName, long[] cachedArray)Returns ownership of array to cachestatic voidrelease(java.lang.String arrayName, short[] cachedArray)Returns ownership of array to cachestatic voidrelease(java.lang.String arrayName, java.lang.String[] cachedArray)Returns ownership of array to cache
-
-
-
Method Detail
-
getCachedBooleanArray
public static boolean[] getCachedBooleanArray(java.lang.String arrayName, int size)Returns cached large recurring primitive arrays, e.g. to be used in functions where often large temporary arrays are needed but that are otherwise outside the function scope not needed.N.B. do not forget to release/return ownership of the array via
release(java.lang.String, boolean[])- Parameters:
arrayName- unique array namesize- requested array size- Returns:
- cached copy (N.B. removed from internal HashMap)
-
getCachedByteArray
public static byte[] getCachedByteArray(java.lang.String arrayName, int size)Returns cached large recurring primitive arrays, e.g. to be used in functions where often large temporary arrays are needed but that are otherwise outside the function scope not needed.N.B. do not forget to release/return ownership of the array via
release(java.lang.String, boolean[])- Parameters:
arrayName- unique array namesize- requested array size- Returns:
- cached copy (N.B. removed from internal HashMap)
-
getCachedDoubleArray
public static double[] getCachedDoubleArray(java.lang.String arrayName, int size)Returns cached large recurring primitive arrays, e.g. to be used in functions where often large temporary arrays are needed but that are otherwise outside the function scope not needed.N.B. do not forget to release/return ownership of the array via
release(java.lang.String, boolean[])- Parameters:
arrayName- unique array namesize- requested array size- Returns:
- cached copy (N.B. removed from internal HashMap)
-
getCachedFloatArray
public static float[] getCachedFloatArray(java.lang.String arrayName, int size)Returns cached large recurring primitive arrays, e.g. to be used in functions where often large temporary arrays are needed but that are otherwise outside the function scope not needed.N.B. do not forget to release/return ownership of the array via
release(java.lang.String, boolean[])- Parameters:
arrayName- unique array namesize- requested array size- Returns:
- cached copy (N.B. removed from internal HashMap)
-
getCachedIntArray
public static int[] getCachedIntArray(java.lang.String arrayName, int size)Returns cached large recurring primitive arrays, e.g. to be used in functions where often large temporary arrays are needed but that are otherwise outside the function scope not needed.N.B. do not forget to release/return ownership of the array via
release(java.lang.String, boolean[])- Parameters:
arrayName- unique array namesize- requested array size- Returns:
- cached copy (N.B. removed from internal HashMap)
-
getCachedLongArray
public static long[] getCachedLongArray(java.lang.String arrayName, int size)Returns cached large recurring primitive arrays, e.g. to be used in functions where often large temporary arrays are needed but that are otherwise outside the function scope not needed.N.B. do not forget to release/return ownership of the array via
release(java.lang.String, boolean[])- Parameters:
arrayName- unique array namesize- requested array size- Returns:
- cached copy (N.B. removed from internal HashMap)
-
getCachedShortArray
public static short[] getCachedShortArray(java.lang.String arrayName, int size)Returns cached large recurring primitive arrays, e.g. to be used in functions where often large temporary arrays are needed but that are otherwise outside the function scope not needed.N.B. do not forget to release/return ownership of the array via
release(java.lang.String, boolean[])- Parameters:
arrayName- unique array namesize- requested array size- Returns:
- cached copy (N.B. removed from internal HashMap)
-
getCachedStringArray
public static java.lang.String[] getCachedStringArray(java.lang.String arrayName, int size)Returns cached large recurring primitive arrays, e.g. to be used in functions where often large temporary arrays are needed but that are otherwise outside the function scope not needed.N.B. do not forget to release/return ownership of the array via
release(java.lang.String, boolean[])- Parameters:
arrayName- unique array namesize- requested array size- Returns:
- cached copy (N.B. removed from internal HashMap)
-
release
public static void release(java.lang.String arrayName, boolean[] cachedArray)Returns ownership of array to cache- Parameters:
arrayName- unique array namecachedArray- the array to be released/return ownership to the cache
-
release
public static void release(java.lang.String arrayName, byte[] cachedArray)Returns ownership of array to cache- Parameters:
arrayName- unique array namecachedArray- the array to be released/return ownership to the cache
-
release
public static void release(java.lang.String arrayName, double[] cachedArray)Returns ownership of array to cache- Parameters:
arrayName- unique array namecachedArray- the array to be released/return ownership to the cache
-
release
public static void release(java.lang.String arrayName, float[] cachedArray)Returns ownership of array to cache- Parameters:
arrayName- unique array namecachedArray- the array to be released/return ownership to the cache
-
release
public static void release(java.lang.String arrayName, int[] cachedArray)Returns ownership of array to cache- Parameters:
arrayName- unique array namecachedArray- the array to be released/return ownership to the cache
-
release
public static void release(java.lang.String arrayName, long[] cachedArray)Returns ownership of array to cache- Parameters:
arrayName- unique array namecachedArray- the array to be released/return ownership to the cache
-
release
public static void release(java.lang.String arrayName, short[] cachedArray)Returns ownership of array to cache- Parameters:
arrayName- unique array namecachedArray- the array to be released/return ownership to the cache
-
release
public static void release(java.lang.String arrayName, java.lang.String[] cachedArray)Returns ownership of array to cache- Parameters:
arrayName- unique array namecachedArray- the array to be released/return ownership to the cache
-
-