public class LeastRecentlyUsedCache<K,V> extends LinkedHashMap<K,V>
LinkedHashMap
. This cache can hold a fixed maximum number of
elements; if a new element is added, and the cache is full, the least recently used entry is removed.AbstractMap.SimpleEntry<K,V>, AbstractMap.SimpleImmutableEntry<K,V>
Modifier and Type | Field and Description |
---|---|
private int |
cacheSize |
private static long |
serialVersionUID |
Constructor and Description |
---|
LeastRecentlyUsedCache(int size)
Creates a new least-recently-used cache.
|
Modifier and Type | Method and Description |
---|---|
protected boolean |
removeEldestEntry(Map.Entry<K,V> eldest) |
clear, containsValue, get
clone, containsKey, entrySet, isEmpty, keySet, put, putAll, remove, size, values
equals, hashCode, toString
private static final long serialVersionUID
private int cacheSize
public LeastRecentlyUsedCache(int size)
size
- the maximum number of entries that will be kept in this cache.protected boolean removeEldestEntry(Map.Entry<K,V> eldest)
removeEldestEntry
in class LinkedHashMap<K,V>