public class LRUCache<K,V> extends LinkedHashMap<K,V>
AbstractMap.SimpleEntry<K,V>, AbstractMap.SimpleImmutableEntry<K,V>
Modifier and Type | Field and Description |
---|---|
protected int |
capacity |
Constructor and Description |
---|
LRUCache(int cap)
LinkedHashMap(16, 0.75F, true).
|
LRUCache(int cap,
boolean accessOrder)
LinkedHashMap(16, 0.75F, accessOrder).
|
Modifier and Type | Method and Description |
---|---|
protected boolean |
removeEldestEntry(Map.Entry<K,V> eldest) |
void |
setCapacity(int cap)
Set capacity of cache.
|
clear, containsValue, entrySet, forEach, get, getOrDefault, keySet, replaceAll, values
clone, compute, computeIfAbsent, computeIfPresent, containsKey, isEmpty, merge, put, putAll, putIfAbsent, remove, remove, replace, replace, size
equals, hashCode, toString
finalize, getClass, notify, notifyAll, wait, wait, wait
compute, computeIfAbsent, computeIfPresent, containsKey, equals, hashCode, isEmpty, merge, put, putAll, putIfAbsent, remove, remove, replace, replace, size
public LRUCache(int cap, boolean accessOrder)
cap
- capacity of this cache. (0 means infinite capacity)accessOrder
- cache behavior LRU / FIFO. true
... LRU, false
... FIFO.public LRUCache(int cap)
cap
- capacity of this cache. (0 means infinite capacity)public void setCapacity(int cap)
cap
- new capacity of this cache. (0 means infinite capacity)protected boolean removeEldestEntry(Map.Entry<K,V> eldest)
removeEldestEntry
in class LinkedHashMap<K,V>
EDB Working Group at Tue Jun 10 17:08:59 JST 2025