public class FutureMap<K,V> extends java.lang.Object implements ComputingMap<K,V>
| Modifier and Type | Class and Description |
|---|---|
class |
FutureMap.PreparationThread |
| Constructor and Description |
|---|
FutureMap(java.util.function.Function<K,V> function) |
FutureMap(java.util.function.Function<K,V> function,
java.util.Comparator<K> comparator) |
| 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.
|
V |
get(K key,
boolean cancellable) |
java.util.Set<K> |
getKeys() |
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) |
boolean |
remove(K key)
Remove the given key and it's associated computed value from the map.
|
V |
removeGet(K key)
Remove the given key and it's associated computed value from the map.
|
V |
removeGet(K key,
boolean cancellable) |
java.util.Collection<V> |
values() |
void |
waitForAll() |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitisEmpty, putAll, putGet, removeAllsizepublic 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 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 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 boolean remove(K key)
ComputingMapremove in interface ComputingMap<K,V>key - The key to remove.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>public void waitForAll()
public java.util.Set<K> getKeys()