|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.waveset.util.LRUCache
A simple implementation of Map that limits the number of entries and, when the limit is reached, scavenges the least recently used item to replace with the new item. This is an unsynchronized collection. If you use this class from multiple threads, you must do it in a synchronized context, or use Collections.synchronized map. For example: LRUCache lruCache = new LRUCache(1000); Map syncMap = Collections.synchronizedMap(lruCache); After this, you would use syncMap for all map access. If you need to get at an LRUCache specific method, first synchronize on the syncMap, eg: synchronized(syncMap) { int listSize = lruCache.getMRUOrderedKeyList().size(); int mapSize = lruCache.size(); }
Nested Class Summary | |
static class |
LRUCache.CacheReport
|
Nested classes inherited from class java.util.Map |
java.util.Map.Entry |
Field Summary | |
static java.lang.String |
code_id
|
Constructor Summary | |
LRUCache(int size)
Create a cache limited to @param size elements |
|
LRUCache(int size,
java.util.Map map)
Create a cache limited to @param size elements. |
Method Summary | |
void |
clear()
|
boolean |
containsKey(java.lang.Object key)
|
boolean |
containsValue(java.lang.Object value)
|
java.util.Set |
entrySet()
|
boolean |
equals(java.lang.Object o)
|
java.lang.Object |
get(java.lang.Object key)
Get the requested object. |
LRUCache.CacheReport |
getCacheReport()
|
java.util.LinkedList |
getLRUOrderedKeyList()
Return a list of keys in MRU order. |
java.util.LinkedList |
getMRUOrderedKeyList()
Return a list of keys in MRU order. |
int |
getNumAdds()
|
int |
getNumHits()
|
int |
getNumMisses()
|
int |
getNumReplacements()
|
int |
getSizeLimit()
|
boolean |
isEmpty()
|
java.util.Set |
keySet()
|
static void |
main(java.lang.String[] args)
|
java.lang.Object |
peek(java.lang.Object key)
Get the requested object. |
java.lang.Object |
put(java.lang.Object key,
java.lang.Object value)
|
void |
putAll(java.util.Map t)
|
java.lang.Object |
remove(java.lang.Object key)
|
int |
size()
|
java.util.Collection |
values()
|
Methods inherited from class java.lang.Object |
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface java.util.Map |
hashCode |
Field Detail |
public static final java.lang.String code_id
Constructor Detail |
public LRUCache(int size)
public LRUCache(int size, java.util.Map map)
Method Detail |
public int size()
size
in interface java.util.Map
public boolean isEmpty()
isEmpty
in interface java.util.Map
public boolean containsKey(java.lang.Object key)
containsKey
in interface java.util.Map
public boolean containsValue(java.lang.Object value)
containsValue
in interface java.util.Map
public java.lang.Object get(java.lang.Object key)
get
in interface java.util.Map
public java.lang.Object peek(java.lang.Object key)
public java.lang.Object put(java.lang.Object key, java.lang.Object value)
put
in interface java.util.Map
public java.lang.Object remove(java.lang.Object key)
remove
in interface java.util.Map
public void putAll(java.util.Map t)
putAll
in interface java.util.Map
public void clear()
clear
in interface java.util.Map
public java.util.Set keySet()
keySet
in interface java.util.Map
public java.util.Collection values()
values
in interface java.util.Map
public java.util.Set entrySet()
entrySet
in interface java.util.Map
public java.util.LinkedList getMRUOrderedKeyList()
public java.util.LinkedList getLRUOrderedKeyList()
public boolean equals(java.lang.Object o)
equals
in interface java.util.Map
public int getNumAdds()
public int getNumReplacements()
public int getNumHits()
public int getNumMisses()
public int getSizeLimit()
public LRUCache.CacheReport getCacheReport()
public static void main(java.lang.String[] args)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |