public class LRUMap<K,V> extends LinkedHashMap<K,V>
LinkedHashMap.
This cache has a fixed maximum number of elements (cacheSize).
If the cache is full and another entry is added, the LRU (least recently
used) entry is dropped.
Note: This class is not thread-safe.
| 限定符和类型 | 类和说明 |
|---|---|
static interface |
LRUMap.RemovalListener<K,V>
An object that can receive a notification when an entry is removed from a LRUMap.
|
AbstractMap.SimpleEntry<K,V>, AbstractMap.SimpleImmutableEntry<K,V>| 构造器和说明 |
|---|
LRUMap(int cacheSize) |
LRUMap(int cacheSize,
LRUMap.RemovalListener<K,V> removalListener) |
| 限定符和类型 | 方法和说明 |
|---|---|
protected boolean |
removeEldestEntry(Map.Entry<K,V> eldest) |
clear, containsValue, entrySet, forEach, get, getOrDefault, keySet, replaceAll, valuesclone, compute, computeIfAbsent, computeIfPresent, containsKey, isEmpty, merge, put, putAll, putIfAbsent, remove, remove, replace, replace, sizeequals, hashCode, toStringcompute, computeIfAbsent, computeIfPresent, containsKey, equals, hashCode, isEmpty, merge, put, putAll, putIfAbsent, remove, remove, replace, replace, sizepublic LRUMap(int cacheSize)
public LRUMap(int cacheSize,
LRUMap.RemovalListener<K,V> removalListener)
protected boolean removeEldestEntry(Map.Entry<K,V> eldest)
removeEldestEntry 在类中 LinkedHashMap<K,V>Copyright © 2014–2020 The Apache Software Foundation. All rights reserved.