TKey - - type of the key.TValue - - type of the value.public class BlockingHashMap<TKey,TValue> extends Object
Values are stored as weak references, and will be automatically removed once they've all been dereferenced.
| Constructor and Description |
|---|
BlockingHashMap()
Initialize a new map.
|
| Modifier and Type | Method and Description |
|---|---|
static <TKey,TValue> |
create()
Initialize a new map.
|
TValue |
get(TKey key)
Waits until a value has been associated with the given key, and then retrieves that value.
|
TValue |
get(TKey key,
long timeout,
TimeUnit unit)
Waits until a value has been associated with the given key, and then retrieves that value.
|
TValue |
get(TKey key,
long timeout,
TimeUnit unit,
boolean ignoreInterrupted)
Waits until a value has been associated with the given key, and then retrieves that value.
|
Set<TKey> |
keys() |
static <TKey,TValue> |
newInvalidCacheLoader()
Retrieve a cache loader that will always throw an exception.
|
TValue |
put(TKey key,
TValue value)
Associate a given key with the given value.
|
TValue |
putIfAbsent(TKey key,
TValue value)
If and only if a key is not present in the map will it be associated with the given value.
|
int |
size() |
Collection<TValue> |
values() |
public static <TKey,TValue> com.google.common.cache.CacheLoader<TKey,TValue> newInvalidCacheLoader()
TKey - Type of the keyTValue - Type of the valuepublic static <TKey,TValue> BlockingHashMap<TKey,TValue> create()
TKey - Type of the keyTValue - Type of the valuepublic TValue get(TKey key) throws InterruptedException
key - - the key whose associated value is to be returnedInterruptedException - If the current thread got interrupted while waiting.public TValue get(TKey key, long timeout, TimeUnit unit) throws InterruptedException
key - - the key whose associated value is to be returnedtimeout - - the amount of time to wait until an association has been made.unit - - unit of timeout.InterruptedException - If the current thread got interrupted while waiting.public TValue get(TKey key, long timeout, TimeUnit unit, boolean ignoreInterrupted) throws InterruptedException
If timeout is zero, this method will return immediately if it can't find an socket injector.
key - - the key whose associated value is to be returnedtimeout - - the amount of time to wait until an association has been made.unit - - unit of timeout.ignoreInterrupted - - TRUE if we should ignore the thread being interrupted, FALSE otherwise.InterruptedException - If the current thread got interrupted while waiting.public TValue put(TKey key, TValue value)
Wakes up any blocking getters on this specific key.
key - - the key to associate.value - - the value.public TValue putIfAbsent(TKey key, TValue value)
key - - the key to associate.value - - the value to associate.public int size()
public Collection<TValue> values()
Copyright © 2012–2017 Comphenix and dmulloy2. Licensed under the GNU GPL v2.