Class IntegerLruCache
java.lang.Object
com.ibm.j9ddr.corereaders.tdump.zebedee.util.AbstractHashMap
com.ibm.j9ddr.corereaders.tdump.zebedee.util.AbstractLruCache
com.ibm.j9ddr.corereaders.tdump.zebedee.util.IntegerLruCache
- All Implemented Interfaces:
Serializable
This class provides an LRU (Least Recently Used) cache which maps integer keys to int values.
See the description in the superclass
AbstractLruCache
for more
details.
Like its sibling IntegerMap
it is low footprint. Note that the value -1 is not allowed
(see discussion in IntegerMap
).- See Also:
-
Constructor Summary
-
Method Summary
Methods declared in class com.ibm.j9ddr.corereaders.tdump.zebedee.util.AbstractLruCache
getIndexAndPromote, putIndexAndPromote
Methods declared in class com.ibm.j9ddr.corereaders.tdump.zebedee.util.AbstractHashMap
getKeys, getKeysArray, size
-
Constructor Details
-
IntegerLruCache
public IntegerLruCache(int maxSize) Create a new IntegerLruCache.- Parameters:
maxSize
- the maximum size the cache can grow to
-
-
Method Details
-
get
public int get(long key) Returns the value mapped by the given key. Also promotes this key to the most recently used.- Returns:
- the value or -1 if it cannot be found
-
put
public void put(long key, int value) Add the key/value pair to the map. The value must not be -1. -
main
Run some basic tests on this class.
-