org.stanwood.media.collections
Class LRUMapCache<K,V>

java.lang.Object
  extended by java.util.AbstractMap<K,V>
      extended by java.util.HashMap<K,V>
          extended by java.util.LinkedHashMap<K,V>
              extended by org.stanwood.media.collections.LRUMapCache<K,V>
Type Parameters:
K - The map key
V - 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 Class Summary
 
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
 
Method Summary
 boolean containsKey(java.lang.Object key)
          
 V get(java.lang.Object key)
          
protected  boolean removeEldestEntry(java.util.Map.Entry<K,V> eldest)
           
 
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
 

Constructor Detail

LRUMapCache

public LRUMapCache(int capacity)
The constructor

Parameters:
capacity - The maximum capacity (number of entries) of the cache
Method Detail

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>