Package net.sf.saxon.sort
Class LRUCache
- java.lang.Object
-
- net.sf.saxon.sort.LRUCache
-
public class LRUCache extends java.lang.Object
An LRU cache, based onLinkedHashMap
. Synthesized and simplified from various published examples of the genre. The methods are not synchronized.
-
-
Constructor Summary
Constructors Constructor Description LRUCache(int cacheSize)
Creates a new LRU cache.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
clear()
Clear the cachejava.lang.Object
get(java.lang.Object key)
Retrieves an entry from the cache.
The retrieved entry becomes the most recently used entry.void
put(java.lang.Object key, java.lang.Object value)
Adds an entry to this cache.
-
-
-
Method Detail
-
get
public java.lang.Object get(java.lang.Object key)
Retrieves an entry from the cache.
The retrieved entry becomes the most recently used entry.- Parameters:
key
- the key whose associated value is to be returned.- Returns:
- the value associated to this key, or null if no value with this key exists in the cache.
-
put
public void put(java.lang.Object key, java.lang.Object value)
Adds an entry to this cache. If the cache is full, the LRU (least recently used) entry is dropped.- Parameters:
key
- the key with which the specified value is to be associated.value
- a value to be associated with the specified key.
-
clear
public void clear()
Clear the cache
-
-