org.varienaja.util
Class LRUMap<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.varienaja.util.LRUMap<K,V>
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, java.util.Map<K,V>

public class LRUMap<K,V>
extends java.util.LinkedHashMap<K,V>

LRU-cache. When elements are added, the LRU-elements will be deleted when the cache is full.

Author:
Varienaja
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
LRUMap(java.lang.String name, int max_entries)
          Creates an instance of a LRU-cache.
 
Method Summary
 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, containsKey, 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
containsKey, entrySet, equals, hashCode, isEmpty, keySet, put, putAll, remove, size, values
 

Constructor Detail

LRUMap

public LRUMap(java.lang.String name,
              int max_entries)
Creates an instance of a LRU-cache.

Parameters:
name - The name of this LRU-cache (for logging purposes)
max_entries - The maximum size of this cache.
Method Detail

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>

removeEldestEntry

protected boolean removeEldestEntry(java.util.Map.Entry<K,V> eldest)
Overrides:
removeEldestEntry in class java.util.LinkedHashMap<K,V>


Copyright © 2010 A.J.V.. All Rights Reserved.