|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.google.common.collect.CustomConcurrentHashMap.Builder
public static final class CustomConcurrentHashMap.Builder
Builds a custom concurrent hash map.
| Constructor Summary | |
|---|---|
CustomConcurrentHashMap.Builder()
|
|
| Method Summary | ||
|---|---|---|
|
buildComputingMap(CustomConcurrentHashMap.ComputingStrategy<K,V,E> strategy,
Function<? super K,? extends V> computer)
Creates a ConcurrentMap, backed by the given strategy, that
supports atomic, on-demand computation of values. |
|
|
buildMap(CustomConcurrentHashMap.Strategy<K,V,E> strategy)
Creates a new concurrent hash map backed by the given strategy. |
|
CustomConcurrentHashMap.Builder |
concurrencyLevel(int concurrencyLevel)
Guides the allowed concurrency among update operations. |
|
CustomConcurrentHashMap.Builder |
initialCapacity(int initialCapacity)
Sets a custom initial capacity (defaults to 16). |
|
CustomConcurrentHashMap.Builder |
loadFactor(float loadFactor)
Sets a custom load factor (defaults to 0.75). |
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public CustomConcurrentHashMap.Builder()
| Method Detail |
|---|
public CustomConcurrentHashMap.Builder loadFactor(float loadFactor)
java.lang.IllegalArgumentException - if loadFactor <= 0public CustomConcurrentHashMap.Builder initialCapacity(int initialCapacity)
java.lang.IllegalArgumentException - if initialCapacity < 0public CustomConcurrentHashMap.Builder concurrencyLevel(int concurrencyLevel)
java.lang.IllegalArgumentException - if concurrencyLevel < 0public <K,V,E> java.util.concurrent.ConcurrentMap<K,V> buildMap(CustomConcurrentHashMap.Strategy<K,V,E> strategy)
K - the type of keys to be stored in the returned mapV - the type of values to be stored in the returned mapE - the type of internal entry to be stored in the returned mapstrategy - used to implement and manipulate the entries
java.lang.NullPointerException - if strategy is null
public <K,V,E> java.util.concurrent.ConcurrentMap<K,V> buildComputingMap(CustomConcurrentHashMap.ComputingStrategy<K,V,E> strategy,
Function<? super K,? extends V> computer)
ConcurrentMap, backed by the given strategy, that
supports atomic, on-demand computation of values. Map.get(java.lang.Object)
returns the value corresponding to the given key, atomically computes
it using the computer function passed to this builder, or waits for
another thread to compute the value if necessary. Only one value will
be computed for each key at a given time.
If an entry's value has not finished computing yet, query methods
besides Map.get(java.lang.Object) return immediately as if an entry
doesn't exist. In other words, an entry isn't externally visible until
the value's computation completes.
Map.get(java.lang.Object) in the returned map implementation throws:
NullPointerException if the key is null or the
computer returns nullComputationException wrapping an exception thrown by the
computationNote: Callers of get() must ensure that the key
argument is of type K. Map.get() takes Object,
so the key type is not checked at compile time. Passing an object of
a type other than K can result in that object being unsafely
passed to the computer function as type K not to mention the
unsafe key being stored in the map.
K - the type of keys to be stored in the returned mapV - the type of values to be stored in the returned mapE - the type of internal entry to be stored in the returned mapstrategy - used to implement and manipulate the entriescomputer - used to compute values for keys
java.lang.NullPointerException - if strategy or computer is null
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||