Top Description Fields Constructors Methods
org.tukaani.xz

public Class ResettableArrayCache

extends ArrayCache
Class Inheritance
Imports
java.util.ArrayList, .List

An ArrayCache wrapper that remembers what has been allocated and allows returning all allocations to the underlying cache at once.
Since
1.7

Field Summary

Modifier and TypeField and Description
private final ArrayCache
private final List<byte[]>
private final List<int[]>

Constructor Summary

AccessConstructor and Description
public
ResettableArrayCache(ArrayCache arrayCache)

Creates a new ResettableArrayCache based on the given ArrayCache.

Method Summary

Modifier and TypeMethod and Description
public byte[]
getByteArray(int
the minimum size of the array to allocate; an implementation may return an array that is larger than the given size
size
,
boolean
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 array
fillWithZeros
)

Overrides org.tukaani.xz.ArrayCache.getByteArray.

Allocates a new byte array.
public int[]
getIntArray(int
the minimum size of the array to allocate; an implementation may return an array that is larger than the given size
size
,
boolean
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 array
fillWithZeros
)

Overrides org.tukaani.xz.ArrayCache.getIntArray.

Allocates a new int array.
public void
putArray(byte[] array)

Overrides org.tukaani.xz.ArrayCache.putArray.

Puts the given byte array to the cache.
public void
putArray(int[] array)

Overrides org.tukaani.xz.ArrayCache.putArray.

Puts the given int array to the cache.
public void
reset()

Puts all allocated arrays back to the underlying ArrayCache that haven't already been put there with a call to putArray.

Inherited from org.tukaani.xz.ArrayCache:
getDefaultCachegetDummyCachesetDefaultCache

Field Detail

arrayCacheback to summary
private final ArrayCache arrayCache
byteArraysback to summary
private final List<byte[]> byteArrays
intArraysback to summary
private final List<int[]> intArrays

Constructor Detail

ResettableArrayCacheback to summary
public ResettableArrayCache(ArrayCache arrayCache)

Creates a new ResettableArrayCache based on the given ArrayCache.

Method Detail

getByteArrayback to summary
public byte[] getByteArray(int size, boolean fillWithZeros)

Overrides org.tukaani.xz.ArrayCache.getByteArray.

Doc from org.tukaani.xz.ArrayCache.getByteArray.

Allocates a new byte array.

This implementation simply returns new byte[size].

Parameters
size:int

the minimum size of the array to allocate; an implementation may return an array that is larger than the given size

fillWithZeros:boolean

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 array

getIntArrayback to summary
public int[] getIntArray(int size, boolean fillWithZeros)

Overrides org.tukaani.xz.ArrayCache.getIntArray.

Doc from org.tukaani.xz.ArrayCache.getIntArray.

Allocates a new int array.

This implementation simply returns new int[size].

Parameters
size:int

the minimum size of the array to allocate; an implementation may return an array that is larger than the given size

fillWithZeros:boolean

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 array

putArrayback to summary
public void putArray(byte[] array)

Overrides org.tukaani.xz.ArrayCache.putArray.

Doc from org.tukaani.xz.ArrayCache.putArray.

Puts the given byte array to the cache. The caller must no longer use the array.

This implementation does nothing.

putArrayback to summary
public void putArray(int[] array)

Overrides org.tukaani.xz.ArrayCache.putArray.

Doc from org.tukaani.xz.ArrayCache.putArray.

Puts the given int array to the cache. The caller must no longer use the array.

This implementation does nothing.

resetback to summary
public void reset()

Puts all allocated arrays back to the underlying ArrayCache that haven't already been put there with a call to putArray.