public class ResettableArrayCache extends ArrayCache
Constructor | Description |
---|---|
ResettableArrayCache(ArrayCache arrayCache) |
Creates a new ResettableArrayCache based on the given ArrayCache.
|
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 to
putArray . |
getDefaultCache, getDummyCache, setDefaultCache
public ResettableArrayCache(ArrayCache arrayCache)
public byte[] getByteArray(int size, boolean fillWithZeros)
ArrayCache
This implementation simply returns new byte[size]
.
getByteArray
in class ArrayCache
size
- the minimum size of the array to allocate;
an implementation may return an array that
is larger than the given size
fillWithZeros
- if true, the caller expects that the first
size
elements in the array are zero;
if false, the array contents can be anything,
which speeds things up when reusing a cached
arraypublic void putArray(byte[] array)
ArrayCache
This implementation does nothing.
putArray
in class ArrayCache
public int[] getIntArray(int size, boolean fillWithZeros)
ArrayCache
This implementation simply returns new int[size]
.
getIntArray
in class ArrayCache
size
- the minimum size of the array to allocate;
an implementation may return an array that
is larger than the given size
fillWithZeros
- if true, the caller expects that the first
size
elements in the array are zero;
if false, the array contents can be anything,
which speeds things up when reusing a cached
arraypublic void putArray(int[] array)
ArrayCache
This implementation does nothing.
putArray
in class ArrayCache
public void reset()
putArray
.