zoukankan      html  css  js  c++  java
  • LruCache

    added in API level 12

    A cache that holds strong references to a limited number of values.Each time a value is accessed,it is moved to the headof a queue.When a value is added to a full cache,

    the value at the end of that queue is evicted and may become eligible for garbage collection.

    By default, the cache size is measured in the number of entries. Override sizeOf(K, V) to size the cache in different units. For example, this cache is limited to 4MiB of bitmaps:

       int cacheSize = 4 * 1024 * 1024; // 4MiB
       LruCache<String, Bitmap> bitmapCache = new LruCache<String, Bitmap>(cacheSize) {
           protected int sizeOf(String key, Bitmap value) {
               return value.getByteCount();
           }
       }

    /**
    * Returns the size of the entry for {@code key} and {@code value} in
    * user-defined units. The default implementation returns 1 so that size
    * is the number of entries and max size is the maximum number of entries.
    *
    * <p>An entry's size must not change while it is in the cache.
    */
    protected int sizeOf(K key, V value) {
    return 1;
    }
     
  • 相关阅读:
    GitHub之初体验
    梦过去了
    转载:获取ISAPI_Rewrite重写后的URL
    看《分手合约》
    我们的家
    一盏灯的思考
    网站爱好者:开篇文
    致我们终将逝去的青春
    一起看看百度转码有多无耻!
    RPM
  • 原文地址:https://www.cnblogs.com/jianglijs/p/7456410.html
Copyright © 2011-2022 走看看