Package org.tukaani.xz
Class ResettableArrayCache
- java.lang.Object
-
- org.tukaani.xz.ArrayCache
-
- org.tukaani.xz.ResettableArrayCache
-
public class ResettableArrayCache extends ArrayCache
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
Constructors Constructor Description ResettableArrayCache(ArrayCache arrayCache)
Creates a new ResettableArrayCache based on the given ArrayCache.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description byte[]
getByteArray(int size, boolean fillWithZeros)
Allocates a new byte array.int[]
getIntArray(int size, boolean fillWithZeros)
Allocates a new int array.void
putArray(byte[] array)
Puts the given byte array to the cache.void
putArray(int[] array)
Puts the given int array to the cache.void
reset()
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.tukaani.xz.ArrayCache
getDefaultCache, getDummyCache, setDefaultCache
-
-
-
-
Constructor Detail
-
ResettableArrayCache
public ResettableArrayCache(ArrayCache arrayCache)
Creates a new ResettableArrayCache based on the given ArrayCache.
-
-
Method Detail
-
getByteArray
public byte[] getByteArray(int size, boolean fillWithZeros)
Description copied from class:ArrayCache
Allocates a new byte array.This implementation simply returns
new byte[size]
.- Overrides:
getByteArray
in classArrayCache
- Parameters:
size
- the minimum size of the array to allocate; an implementation may return an array that is larger than the givensize
fillWithZeros
- if true, the caller expects that the firstsize
elements 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:ArrayCache
Puts the given byte array to the cache. The caller must no longer use the array.This implementation does nothing.
- Overrides:
putArray
in classArrayCache
-
getIntArray
public int[] getIntArray(int size, boolean fillWithZeros)
Description copied from class:ArrayCache
Allocates a new int array.This implementation simply returns
new int[size]
.- Overrides:
getIntArray
in classArrayCache
- Parameters:
size
- the minimum size of the array to allocate; an implementation may return an array that is larger than the givensize
fillWithZeros
- if true, the caller expects that the firstsize
elements 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:ArrayCache
Puts the given int array to the cache. The caller must no longer use the array.This implementation does nothing.
- Overrides:
putArray
in 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
.
-
-