net.didion.jwnl.util.cache
Class LRUCache
java.lang.Object
java.util.AbstractMap
java.util.HashMap
java.util.LinkedHashMap
net.didion.jwnl.util.cache.LRUCache
- All Implemented Interfaces:
- Cache, java.lang.Cloneable, java.util.Map, java.io.Serializable
- public class LRUCache
- extends java.util.LinkedHashMap
- implements Cache
A fixed-capacity Cache that stores the most recently used elements. Once the cache reaches
capacity, the least recently used elements will be removed.
- See Also:
- Serialized Form
|
Constructor Summary |
LRUCache(int capacity)
|
|
Method Summary |
int |
getCapacity()
Returns the maximum number of elements the cache can hold. |
int |
getSize()
Returns the current size of the cache. |
boolean |
isFull()
|
protected boolean |
removeEldestEntry(java.util.Map.Entry eldest)
|
int |
setCapacity(int capacity)
Set the maximum number of elements the cache can hold. |
| Methods inherited from class java.util.LinkedHashMap |
clear, containsValue, get |
| 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 |
equals, hashCode |
LRUCache
public LRUCache(int capacity)
- Parameters:
capacity - the maximum number of elements that can be contained in the cache.
isFull
public boolean isFull()
removeEldestEntry
protected boolean removeEldestEntry(java.util.Map.Entry eldest)
setCapacity
public int setCapacity(int capacity)
- Description copied from interface:
Cache
- Set the maximum number of elements the cache can hold.
- Specified by:
setCapacity in interface Cache
getCapacity
public int getCapacity()
- Description copied from interface:
Cache
- Returns the maximum number of elements the cache can hold.
- Specified by:
getCapacity in interface Cache
getSize
public int getSize()
- Description copied from interface:
Cache
- Returns the current size of the cache.
- Specified by:
getSize in interface Cache
JWNL homepage.