public class LRUCacheComputingMap<K,V> extends CacheComputingMap<K,V>
Modifier and Type | Class and Description |
---|---|
protected class |
LRUCacheComputingMap.LinkedEntry |
CacheComputingMap.KeyedReference, CacheComputingMap.ReferenceEntry
ComputingEntryHashMap.ComputingEntry, ComputingEntryHashMap.DeferredEntry, ComputingEntryHashMap.Entry<K,V>
Modifier | Constructor and Description |
---|---|
|
LRUCacheComputingMap(java.util.function.Function<K,V> computation,
int maximumSize,
boolean softReferences) |
protected |
LRUCacheComputingMap(LRUCacheComputingMap<K,V> other) |
Modifier and Type | Method and Description |
---|---|
int |
cacheSize() |
boolean |
clear()
Remove all keys and values from the map.
|
protected ComputingEntryHashMap.Entry<K,V> |
createEntry(K key) |
V |
get(K key)
For the given key, this method should return the value which has been
computed.
|
boolean |
isEmpty() |
boolean |
put(K key)
Enters the key into the map such that a value of type
V will at
some point be computed which will be then returned by any subsequent calls
to ComputingMap.get(K) . |
boolean |
putAll(java.util.Collection<? extends K> keys) |
V |
putGet(K key,
java.util.function.Consumer<V> wasPresent,
java.util.function.Consumer<V> wasMissing) |
boolean |
removeAll(java.util.Set<K> keys) |
clean, removeGet
computation, keySet, putGetImpl, values
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
putGet, remove, removeAll
size
public LRUCacheComputingMap(java.util.function.Function<K,V> computation, int maximumSize, boolean softReferences)
protected LRUCacheComputingMap(LRUCacheComputingMap<K,V> other)
protected ComputingEntryHashMap.Entry<K,V> createEntry(K key)
createEntry
in class CacheComputingMap<K,V>
public int cacheSize()
public V get(K key)
ComputingMap
get
in interface ComputingMap<K,V>
get
in interface ReadOnlyMap<K,V>
get
in class CacheComputingMap<K,V>
key
- The key object for which to return the mapped computed valuepublic boolean put(K key)
ComputingMap
V
will at
some point be computed which will be then returned by any subsequent calls
to ComputingMap.get(K)
.
Generally keys should be immutable, and the computation associated with the
map will be expected to produce identical results each time, so in the case
that the key has already been added to the map most implementations should
just return instantly and do no work. Because of this it also makes little
sense to return the previous value for a key entered more than once.put
in interface ComputingMap<K,V>
put
in class CacheComputingMap<K,V>
key
- The key object to be mapped to a new valuepublic boolean putAll(java.util.Collection<? extends K> keys)
public V putGet(K key, java.util.function.Consumer<V> wasPresent, java.util.function.Consumer<V> wasMissing)
putGet
in interface ComputingMap<K,V>
putGet
in class CacheComputingMap<K,V>
public boolean removeAll(java.util.Set<K> keys)
public boolean clear()
ComputingMap
clear
in interface ComputingMap<K,V>
clear
in class ComputingEntryHashMap<K,V>
public boolean isEmpty()