Interface ArrayPool

All Known Implementing Classes:
LruArrayPool

public interface ArrayPool
Interface for an array pool that pools arrays of different types.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final int
    A standard size to use to increase hit rates when the required size isn't defined.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Clears all arrays from the pool.
    <T> T
    get(int size, Class<T> arrayClass)
    Returns a non-null array of the given type with a length >= to the given size.
    <T> T
    getExact(int size, Class<T> arrayClass)
    Returns a non-null array of the given type with a length exactly equal to the given size.
    <T> void
    put(T array)
    Optionally adds the given array of the given type to the pool.
    <T> void
    put(T array, Class<T> arrayClass)
    Deprecated.
    void
    trimMemory(int level)
    Trims the size to the appropriate level.
  • Field Details

    • STANDARD_BUFFER_SIZE_BYTES

      static final int STANDARD_BUFFER_SIZE_BYTES
      A standard size to use to increase hit rates when the required size isn't defined. Currently 64KB.
      See Also:
  • Method Details

    • put

      @Deprecated <T> void put(T array, Class<T> arrayClass)
      Deprecated.
      Optionally adds the given array of the given type to the pool.

      Arrays may be ignored, for example if the array is larger than the maximum size of the pool.

    • put

      <T> void put(T array)
      Optionally adds the given array of the given type to the pool.

      Arrays may be ignored, for example if the array is larger than the maximum size of the pool.

    • get

      <T> T get(int size, Class<T> arrayClass)
      Returns a non-null array of the given type with a length >= to the given size.

      If an array of the given size isn't in the pool, a new one will be allocated.

      This class makes no guarantees about the contents of the returned array.

      See Also:
    • getExact

      <T> T getExact(int size, Class<T> arrayClass)
      Returns a non-null array of the given type with a length exactly equal to the given size.

      If an array of the given size isn't in the pool, a new one will be allocated.

      This class makes no guarantees about the contents of the returned array.

      See Also:
    • clearMemory

      void clearMemory()
      Clears all arrays from the pool.
    • trimMemory

      void trimMemory(int level)
      Trims the size to the appropriate level.
      Parameters:
      level - A trim specified in ComponentCallbacks2.