|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectedu.toronto.cs.util.caching.AbstractMapCache
edu.toronto.cs.util.caching.NaiveMapCache
public class NaiveMapCache
Fairly simplistic caching.
Field Summary | |
---|---|
int |
DEFAULT_SIZE
|
protected java.util.List |
keylist
|
protected int |
maxsize
|
Fields inherited from class edu.toronto.cs.util.caching.AbstractMapCache |
---|
cache |
Constructor Summary | |
---|---|
NaiveMapCache()
Create a new cache. |
|
NaiveMapCache(int numitems)
Create a new cache with a specified # of items it can store. |
Method Summary | |
---|---|
protected void |
adjustSize()
Adjust the cache size to the specified value. |
java.lang.Object |
get(java.lang.Object key)
Retrieves a value with the specified key from the cache. |
boolean |
isFull()
Determines if the cache is at its maximum capacity. |
java.lang.Object |
put(java.lang.Object key,
java.lang.Object value)
Stores a value and assotiates a key with it. |
java.lang.Object |
remove(java.lang.Object key)
Removes a value with the specified key from the cache. |
void |
resize(int size)
Sets the maximum cache size. |
Methods inherited from class edu.toronto.cs.util.caching.AbstractMapCache |
---|
clear, containsKey, containsValue, entrySet, isEmpty, keySet, size, values |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected java.util.List keylist
protected int maxsize
public final int DEFAULT_SIZE
Constructor Detail |
---|
public NaiveMapCache()
public NaiveMapCache(int numitems)
Method Detail |
---|
public java.lang.Object put(java.lang.Object key, java.lang.Object value)
put
in interface Cache
put
in class AbstractMapCache
key
- -- the key associated with the value.value
- -- value to store.
public java.lang.Object get(java.lang.Object key)
get
in interface Cache
get
in class AbstractMapCache
key
- -- the key associated with the value.
public java.lang.Object remove(java.lang.Object key)
remove
in interface Cache
remove
in class AbstractMapCache
key
- -- the key associated with the value.
public boolean isFull()
isFull
in class AbstractMapCache
public void resize(int size)
AbstractMapCache
resize
in interface Cache
resize
in class AbstractMapCache
size
- -- the maximum cache size.protected void adjustSize()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |