public class CacheComputingMap<K,V> extends ComputingEntryHashMap<K,V>
Modifier and Type | Class and Description |
---|---|
protected class |
CacheComputingMap.KeyedReference |
protected class |
CacheComputingMap.ReferenceEntry |
ComputingEntryHashMap.ComputingEntry, ComputingEntryHashMap.DeferredEntry, ComputingEntryHashMap.Entry<K,V>
Modifier | Constructor and Description |
---|---|
protected |
CacheComputingMap(CacheComputingMap<K,V> other) |
|
CacheComputingMap(java.util.function.Function<K,V> computation,
boolean softReferences) |
|
CacheComputingMap(java.util.function.Function<K,V> computation,
boolean softReferences,
java.util.concurrent.Executor executor) |
Modifier and Type | Method and Description |
---|---|
void |
clean() |
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 |
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) . |
V |
putGet(K key,
java.util.function.Consumer<V> wasPresent,
java.util.function.Consumer<V> wasMissing) |
V |
removeGet(K key)
Remove the given key and it's associated computed value from the map.
|
clear, computation, keySet, putGetImpl, values
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
isEmpty, putAll, putGet, remove, removeAll
size
public CacheComputingMap(java.util.function.Function<K,V> computation, boolean softReferences)
public CacheComputingMap(java.util.function.Function<K,V> computation, boolean softReferences, java.util.concurrent.Executor executor)
protected CacheComputingMap(CacheComputingMap<K,V> other)
public void clean()
protected ComputingEntryHashMap.Entry<K,V> createEntry(K key)
createEntry
in class ComputingEntryHashMap<K,V>
public V get(K key)
ComputingMap
get
in interface ComputingMap<K,V>
get
in interface ReadOnlyMap<K,V>
get
in class ComputingEntryHashMap<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 ComputingEntryHashMap<K,V>
key
- The key object to be mapped to a new valuepublic 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 ComputingEntryHashMap<K,V>
public V removeGet(K key)
ComputingMap
Use of this method may result in worse performance that
ComputingMap.remove(Object)
, as some implementations may cancel value
computation for keys removed by the latter.
removeGet
in interface ComputingMap<K,V>
removeGet
in class ComputingEntryHashMap<K,V>
key
- The key to remove.