Class LruArrayPool

java.lang.Object
com.bumptech.glide.load.engine.bitmap_recycle.LruArrayPool
All Implemented Interfaces:
ArrayPool

public final class LruArrayPool extends Object implements ArrayPool
A fixed size Array Pool that evicts arrays using an LRU strategy to keep the pool under the maximum byte size.
  • Field Summary

    Fields inherited from interface com.bumptech.glide.load.engine.bitmap_recycle.ArrayPool

    STANDARD_BUFFER_SIZE_BYTES
  • Constructor Summary

    Constructors
    Constructor
    Description
     
    LruArrayPool(int maxSize)
    Constructor for a new pool.
  • 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.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • LruArrayPool

      public LruArrayPool()
    • LruArrayPool

      public LruArrayPool(int maxSize)
      Constructor for a new pool.
      Parameters:
      maxSize - The maximum size in integers of the pool.
  • Method Details

    • put

      @Deprecated public <T> void put(T array, Class<T> arrayClass)
      Deprecated.
      Description copied from interface: ArrayPool
      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.

      Specified by:
      put in interface ArrayPool
    • put

      public <T> void put(T array)
      Description copied from interface: ArrayPool
      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.

      Specified by:
      put in interface ArrayPool
    • getExact

      public <T> T getExact(int size, Class<T> arrayClass)
      Description copied from interface: ArrayPool
      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.

      Specified by:
      getExact in interface ArrayPool
      See Also:
    • get

      public <T> T get(int size, Class<T> arrayClass)
      Description copied from interface: ArrayPool
      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.

      Specified by:
      get in interface ArrayPool
      See Also:
    • clearMemory

      public void clearMemory()
      Description copied from interface: ArrayPool
      Clears all arrays from the pool.
      Specified by:
      clearMemory in interface ArrayPool
    • trimMemory

      public void trimMemory(int level)
      Description copied from interface: ArrayPool
      Trims the size to the appropriate level.
      Specified by:
      trimMemory in interface ArrayPool
      Parameters:
      level - A trim specified in ComponentCallbacks2.