|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Object
|
+--java.util.Dictionary
|
+--com.ibm.wbi.util.Cache
|
+--com.ibm.wbi.util.LRUCache
A simple LRU Cache implementation. Basically this is a Hashtable where entries expire on a LRU basis.
Cache,
Hashtable,
Dictionary| Constructor Summary | |
LRUCache()
Constructs an LRUCache with a default capacity of 10. |
|
LRUCache(int maxsize)
Constructs an LRUCache with the specified capacity. |
|
| Method Summary | |
void |
clear()
Clears the cache so that it contains no keys or values. |
java.util.Enumeration |
elements()
Returns an enumeration of the values in this LRUCache. |
java.lang.Object |
get(java.lang.Object key)
Returns the value to which the key is mapped in the cache. |
boolean |
isEmpty()
Tests whether this LRUCache contains no keys. |
java.util.Enumeration |
keys()
Returns an enumeration of the keys in this LRUCache. |
static void |
main(java.lang.String[] argv)
Test driver. |
java.lang.Object |
put(java.lang.Object key,
java.lang.Object value)
Maps the specified key to the specified value in this cache. |
java.lang.Object |
remove(java.lang.Object key)
Removes the specified key and the value to which it is mapped from the cache. |
int |
size()
Returns the number of keys which are mapped to values in this cache. |
java.lang.String |
toString()
Returns a string representation of this cache. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
public LRUCache()
public LRUCache(int maxsize)
maxsize - The capacity of the cache.| Method Detail |
public java.util.Enumeration elements()
elements in class Cachepublic java.lang.Object get(java.lang.Object key)
get in class Cachekey - A key in the cache.null if the key is not mapped to any value.public boolean isEmpty()
isEmpty in class Cachetrue if the cache contains no keys;
false otherwise.public java.util.Enumeration keys()
keys in class Cache
public java.lang.Object put(java.lang.Object key,
java.lang.Object value)
null.put in class Cachekey - The keyvalue - The valuekey was
mapped, or null if key was not mapped
to any value.NullPointerException - If key or
value is null.public java.lang.Object remove(java.lang.Object key)
remove in class Cachekey - The key to be removedkey was mapped, or
null if key was not mapped to any
value.public int size()
size in class Cachepublic void clear()
clear in class Cachepublic java.lang.String toString()
toString in class java.lang.Objectpublic static void main(java.lang.String[] argv)
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||