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 Details

    • ResettableArrayCache

      public ResettableArrayCache​(ArrayCache arrayCache)
      Creates a new ResettableArrayCache based on the given ArrayCache.
  • Method Details

    • 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.