|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.ephman.utils.RandomCache
A class to cache any set of objects
Field Summary | |
protected java.util.HashMap |
hm
|
Constructor Summary | |
RandomCache()
constructs a cache of default elements (17) |
|
RandomCache(int cacheSize)
if cacheSize is greater than 17, initializes the cache with size = the first prime >= cacheSize |
Method Summary | |
void |
flush()
a routine to flush out the cache |
java.lang.Object |
get(java.lang.Object key)
Unsynchronized find of an Object which was hashed on key |
int |
getSize()
Determine the number of elements in the cache never > than maxElements |
void |
put(java.lang.Object key,
java.lang.Object obj)
A synchronized placement of an element into the cache - to guarantee that no more than 1 copy of an item is cached |
void |
putForceUpdate(java.lang.Object key,
java.lang.Object obj)
A synchronized placement of an element into the cache - to guarantee that no more than 1 copy of an item is cached |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected java.util.HashMap hm
Constructor Detail |
public RandomCache()
public RandomCache(int cacheSize)
cacheSize
- the desired cache sizeMethod Detail |
public void flush()
public int getSize()
public java.lang.Object get(java.lang.Object key)
key
- the Object whose hashcode will be used in lookup
public void putForceUpdate(java.lang.Object key, java.lang.Object obj)
key
- the Object whose hashcode should be used to store objobj
- the Object to store in cachepublic void put(java.lang.Object key, java.lang.Object obj)
key
- the Object whose hashcode should be used to store objobj
- the Object to store in cache
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |