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;
    }
     
  • 相关阅读:
    ...
    RUP,XP,敏捷原理
    JSP的内置对象——SESSION
    JSP的内置对象——REQUEST
    节点属性
    RUP,XP,敏捷原理
    寄存器
    设置背景图片
    Java代码空格问题
    数据库常见错误
  • 原文地址:https://www.cnblogs.com/jianglijs/p/7456410.html
Copyright © 2011-2022 走看看