Loading core/java/android/util/LruCache.java +15 −7 Original line number Diff line number Diff line Loading @@ -34,8 +34,8 @@ import java.util.Map; * assume a value will always be returned, even when there's a cache miss. * * <p>By default, the cache size is measured in the number of entries. Override * {@link #sizeOf} to size the cache in different units. For, this cache is * limited to 4MiB of bitmaps: * {@link #sizeOf} to size the cache in different units. For example, this cache * is limited to 4MiB of bitmaps: * <pre> {@code * int cacheSize = 4 * 1024 * 1024; // 4MiB * LruCache<String, Bitmap> bitmapCache = new LruCache<String, Bitmap>(cacheSize) { Loading @@ -43,6 +43,14 @@ import java.util.Map; * return value.getByteCount(); * } * }}</pre> * * <p>This class is thread-safe. Perform multiple cache operations atomically by * synchronizing on the cache: <pre> {@code * synchronized (cache) { * if (cache.get(key) == null) { * cache.put(key, value); * } * }}</pre> */ public class LruCache<K, V> { private final LinkedHashMap<K, V> map; Loading Loading
core/java/android/util/LruCache.java +15 −7 Original line number Diff line number Diff line Loading @@ -34,8 +34,8 @@ import java.util.Map; * assume a value will always be returned, even when there's a cache miss. * * <p>By default, the cache size is measured in the number of entries. Override * {@link #sizeOf} to size the cache in different units. For, this cache is * limited to 4MiB of bitmaps: * {@link #sizeOf} to size the cache in different units. For example, this cache * is limited to 4MiB of bitmaps: * <pre> {@code * int cacheSize = 4 * 1024 * 1024; // 4MiB * LruCache<String, Bitmap> bitmapCache = new LruCache<String, Bitmap>(cacheSize) { Loading @@ -43,6 +43,14 @@ import java.util.Map; * return value.getByteCount(); * } * }}</pre> * * <p>This class is thread-safe. Perform multiple cache operations atomically by * synchronizing on the cache: <pre> {@code * synchronized (cache) { * if (cache.get(key) == null) { * cache.put(key, value); * } * }}</pre> */ public class LruCache<K, V> { private final LinkedHashMap<K, V> map; Loading