public class ComputingHashMap<K,V> extends java.lang.Object implements ComputingMap<K,V>
| Constructor and Description |
|---|
ComputingHashMap(java.util.function.Function<K,V> computation) |
| Modifier and Type | Method and Description |
|---|---|
boolean |
clear()
Remove all keys and values from the map.
|
V |
get(K key)
For the given key, this method should return the value which has been
computed.
|
java.util.Set<K> |
keySet() |
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.
|
java.util.Collection<V> |
values() |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitisEmpty, putAll, putGet, remove, removeAllsizepublic V get(K key)
ComputingMapget in interface ComputingMap<K,V>get in interface ReadOnlyMap<K,V>key - The key object for which to return the mapped computed valuepublic boolean put(K key)
ComputingMapV 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>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>public java.util.Set<K> keySet()
keySet in interface ComputingMap<K,V>keySet in interface ReadOnlyMap<K,V>public java.util.Collection<V> values()
values in interface ComputingMap<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>key - The key to remove.public boolean clear()
ComputingMapclear in interface ComputingMap<K,V>