org.inria.myriads.snoozecommon.datastructure
Class LRUCache<K,V>
java.lang.Object
java.util.AbstractMap<K,V>
java.util.HashMap<K,V>
java.util.LinkedHashMap<K,V>
org.inria.myriads.snoozecommon.datastructure.LRUCache<K,V>
- Type Parameters:
K
- The keyV
- The value
- All Implemented Interfaces:
- Serializable, Cloneable, Map<K,V>
public class LRUCache<K,V>
- extends LinkedHashMap<K,V>
- implements Serializable
Generic LRU cache implementation.
- Author:
- Eugen Feller
- See Also:
- Serialized Form
Constructor Summary |
LRUCache()
Empty constructor. |
LRUCache(int maxCapacity)
Constructor. |
Methods inherited from interface java.util.Map |
containsKey, entrySet, equals, hashCode, isEmpty, keySet, put, putAll, remove, size, values |
LRUCache
public LRUCache()
- Empty constructor.
LRUCache
public LRUCache(int maxCapacity)
- Constructor.
- Parameters:
maxCapacity
- The maximum capacity
removeEldestEntry
protected boolean removeEldestEntry(Map.Entry<K,V> eldest)
- Determines if the oldest element schould be removed.
- Overrides:
removeEldestEntry
in class LinkedHashMap<K,V>
- Parameters:
eldest
- The eldest element
- Returns:
- true if removed, false otherwise
Copyright © 2012. All Rights Reserved.