org.stanwood.media.collections
Class LRUMapCache<K,V>
java.lang.Object
java.util.AbstractMap<K,V>
java.util.HashMap<K,V>
java.util.LinkedHashMap<K,V>
org.stanwood.media.collections.LRUMapCache<K,V>
- Type Parameters:
K
- The map keyV
- The map value
- All Implemented Interfaces:
- java.io.Serializable, java.lang.Cloneable, java.util.Map<K,V>
public class LRUMapCache<K,V>
- extends java.util.LinkedHashMap<K,V>
A Hash map cache that deletes entries that were access last when a capacity limit is reached
- See Also:
- Serialized Form
Nested classes/interfaces inherited from class java.util.AbstractMap |
java.util.AbstractMap.SimpleEntry<K,V>, java.util.AbstractMap.SimpleImmutableEntry<K,V> |
Constructor Summary |
LRUMapCache(int capacity)
The constructor |
Methods inherited from class java.util.LinkedHashMap |
clear, containsValue |
Methods inherited from class java.util.HashMap |
clone, entrySet, isEmpty, keySet, put, putAll, remove, size, values |
Methods inherited from class java.util.AbstractMap |
equals, hashCode, toString |
Methods inherited from class java.lang.Object |
finalize, getClass, notify, notifyAll, wait, wait, wait |
Methods inherited from interface java.util.Map |
entrySet, equals, hashCode, isEmpty, keySet, put, putAll, remove, size, values |
LRUMapCache
public LRUMapCache(int capacity)
- The constructor
- Parameters:
capacity
- The maximum capacity (number of entries) of the cache
removeEldestEntry
protected boolean removeEldestEntry(java.util.Map.Entry<K,V> eldest)
- Overrides:
removeEldestEntry
in class java.util.LinkedHashMap<K,V>
get
public V get(java.lang.Object key)
-
- Specified by:
get
in interface java.util.Map<K,V>
- Overrides:
get
in class java.util.LinkedHashMap<K,V>
containsKey
public boolean containsKey(java.lang.Object key)
-
- Specified by:
containsKey
in interface java.util.Map<K,V>
- Overrides:
containsKey
in class java.util.HashMap<K,V>