public class LimitedCache<K,V>
extends java.lang.Object
Constructor and Description |
---|
LimitedCache(int capacity)
Construct a cache that will hold (at least) the specified number of entries.
|
Modifier and Type | Method and Description |
---|---|
void |
add(K key,
V value)
Add a value corresponding to a given key.
|
V |
get(K key)
Get a value corresponding to the key, if it was previously cached.
|
java.lang.String |
toString() |
public LimitedCache(int capacity)
capacity
- the number of entries requiredpublic V get(K key)
key
- against which cachednull
if not presentpublic void add(K key, V value)
key
- against which to cache the valuevalue
- to storepublic java.lang.String toString()
toString
in class java.lang.Object