Class ResettableArrayCache
java.lang.Object
org.graalvm.shadowed.org.tukaani.xz.ArrayCache
org.graalvm.shadowed.org.tukaani.xz.ResettableArrayCache
An ArrayCache wrapper that remembers what has been allocated
and allows returning all allocations to the underlying cache at once.
- Since:
- 1.7
-
Constructor Summary
ConstructorsConstructorDescriptionResettableArrayCache(ArrayCache arrayCache) Creates a new ResettableArrayCache based on the given ArrayCache. -
Method Summary
Modifier and TypeMethodDescriptionbyte[]getByteArray(int size, boolean fillWithZeros) Allocates a new byte array.int[]getIntArray(int size, boolean fillWithZeros) Allocates a new int array.voidputArray(byte[] array) Puts the given byte array to the cache.voidputArray(int[] array) Puts the given int array to the cache.voidreset()Puts all allocated arrays back to the underlying ArrayCache that haven't already been put there with a call toputArray.Methods inherited from class org.graalvm.shadowed.org.tukaani.xz.ArrayCache
getDefaultCache, getDummyCache, setDefaultCache
-
Constructor Details
-
ResettableArrayCache
Creates a new ResettableArrayCache based on the given ArrayCache.
-
-
Method Details
-
getByteArray
public byte[] getByteArray(int size, boolean fillWithZeros) Description copied from class:ArrayCacheAllocates a new byte array.This implementation simply returns
new byte[size].- Overrides:
getByteArrayin classArrayCache- Parameters:
size- the minimum size of the array to allocate; an implementation may return an array that is larger than the givensizefillWithZeros- if true, the caller expects that the firstsizeelements in the array are zero; if false, the array contents can be anything, which speeds things up when reusing a cached array
-
putArray
public void putArray(byte[] array) Description copied from class:ArrayCachePuts the given byte array to the cache. The caller must no longer use the array.This implementation does nothing.
- Overrides:
putArrayin classArrayCache
-
getIntArray
public int[] getIntArray(int size, boolean fillWithZeros) Description copied from class:ArrayCacheAllocates a new int array.This implementation simply returns
new int[size].- Overrides:
getIntArrayin classArrayCache- Parameters:
size- the minimum size of the array to allocate; an implementation may return an array that is larger than the givensizefillWithZeros- if true, the caller expects that the firstsizeelements in the array are zero; if false, the array contents can be anything, which speeds things up when reusing a cached array
-
putArray
public void putArray(int[] array) Description copied from class:ArrayCachePuts the given int array to the cache. The caller must no longer use the array.This implementation does nothing.
- Overrides:
putArrayin classArrayCache
-
reset
public void reset()Puts all allocated arrays back to the underlying ArrayCache that haven't already been put there with a call toputArray.
-