Package 

Class LruArrayPool

  • All Implemented Interfaces:
    com.mobwith.imgmodule.load.engine.bitmap_recycle.ArrayPool

    
    public final class LruArrayPool
     implements ArrayPool
                        

    A fixed size Array Pool that evicts arrays using an LRU strategy to keep the pool under the maximum byte size.

    • Constructor Summary

      Constructors 
      Constructor Description
      LruArrayPool()
      LruArrayPool(int maxSize) Constructor for a new pool.
    • Method Summary

      Modifier and Type Method Description
      <T> void put(T array, Class<T> arrayClass) Optionally adds the given array of the given type to the pool.
      synchronized <T> void put(T array) Optionally adds the given array of the given type to the pool.
      synchronized <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.
      synchronized <T> T get(int size, Class<T> arrayClass) Returns a non-null array of the given type with a length >= to the given size.
      synchronized void clearMemory() Clears all arrays from the pool.
      synchronized 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 Detail

      • LruArrayPool

        LruArrayPool()
      • LruArrayPool

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

      • put

        @Deprecated() <T> void put(T array, Class<T> arrayClass)

        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

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

      • getExact

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

      • get

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

      • clearMemory

         synchronized void clearMemory()

        Clears all arrays from the pool.