|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
ObjectFastCache<K,V>
public class FastCache<K,V>
A fast but inflexible cache where the keys are anything, the size is fixed, and a crude LRU policy is enforced. Handles consecutive keys gracefully. Doesn't support resizing, deletion, or iteration (not that these operations would be hard, just that they haven't been needed so far.)
Field Summary | |
---|---|
private FastHashMap<K,V> |
newHash
|
private FastHashMap<K,V> |
oldHash
|
private int |
size
|
static Tester |
tester
Basic regression test |
Constructor Summary | |
---|---|
FastCache(int size)
Construct a new cache. |
Method Summary | |
---|---|
void |
clear()
Clears all entries from the cache |
boolean |
contains(K key)
Check whether the given key is present in the cache |
V |
get(K key)
Retrieve the value for the given key, or null if not found. |
void |
put(K key,
V val)
Add a key/value pair to the cache. |
Methods inherited from class Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private int size
private FastHashMap<K,V> oldHash
private FastHashMap<K,V> newHash
public static final Tester tester
Constructor Detail |
---|
public FastCache(int size)
size
- How large to make each of the two internal hash tables.Method Detail |
---|
public void clear()
public boolean contains(K key)
public V get(K key)
public void put(K key, V val)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |