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 int STANDARD_BUFFER_SIZE_BYTES
      A standard size to use to increase hit rates when the required size isn't defined.
    • Method Summary

      All Methods Instance Methods Abstract Methods Deprecated Methods 
      Modifier and Type Method Description
      void clearMemory()
      Clears all arrays from the pool.
      <T> T get​(int size, java.lang.Class<T> arrayClass)
      Returns a non-null array of the given type with a length >= to the given size.
      <T> T getExact​(int size, java.lang.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, java.lang.Class<T> arrayClass)
      Deprecated.
      void trimMemory​(int level)
      Trims the size to the appropriate level.
    • Field Detail

      • 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:
        Constant Field Values
    • Method Detail

      • put

        @Deprecated
        <T> void put​(T array,
                     java.lang.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,
                  java.lang.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(int, Class)
      • getExact

        <T> T getExact​(int size,
                       java.lang.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:
        get(int, Class)
      • 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.