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 and Description
`ResettableArrayCache(ArrayCache arrayCache)` Creates a new ResettableArrayCache based on the given ArrayCache.

### Method Summary

All Methods Instance Methods Concrete Methods
`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`.

### Methods inherited from class org.tukaani.xz.ArrayCache

`getDefaultCache, getDummyCache, setDefaultCache`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### 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 class `ArrayCache`
Parameters:
  `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 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 class `ArrayCache`

#### 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 class `ArrayCache`
Parameters:
  `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 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 class `ArrayCache`

#### reset

    public void reset()

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