public class BoundedCache<K,V> extends LinkedHashMap<K,V>
Map
that acts as an LRU cache for a fixed number of
elements. Classes may use this to retain a limited nubmer of frequently-used
mappings. For more details see LinkedHashMap
on its access-order.LinkedHashMap
,
Serialized FormAbstractMap.SimpleEntry<K,V>, AbstractMap.SimpleImmutableEntry<K,V>
Constructor and Description |
---|
BoundedCache(int maxSize)
Creates a cache that retains at most
maxSize elements |
Modifier and Type | Method and Description |
---|---|
protected boolean |
removeEldestEntry(Map.Entry<K,V> eldest)
Returns
true if the addition of some entry has caused the current
size of the map to exceed its maximum size. |
clear, containsValue, get
clone, containsKey, entrySet, isEmpty, keySet, put, putAll, remove, size, values
equals, hashCode, toString
public BoundedCache(int maxSize)
maxSize
elementsprotected boolean removeEldestEntry(Map.Entry<K,V> eldest)
true
if the addition of some entry has caused the current
size of the map to exceed its maximum size.removeEldestEntry
in class LinkedHashMap<K,V>
Copyright © 2012. All Rights Reserved.