ch.bind.philib.util
K - type parameter for the map's keys.V - type parameter for the map's values.public interface TimeoutMap<K,V>
pollTimeoutNow() method or two blocking methods:
pollTimeoutBlocking() and pollTimeoutBlocking(long, TimeUnit).| Modifier and Type | Method and Description |
|---|---|
void |
clear()
removes all key-value pairs from this map.
|
boolean |
containsKey(K key)
Check for the existence of a key.
|
V |
get(K key)
Searches a value by its key
|
long |
getTimeToNextTimeout() |
boolean |
isEmpty() |
List<Map.Entry<K,V>> |
pollAllTimeoutNow()
Nonblocking poll for all timed out entries, based on the time of the invocation of this
method.
|
Map.Entry<K,V> |
pollTimeoutBlocking()
Blocking poll for the next entry which is timed out.
|
Map.Entry<K,V> |
pollTimeoutBlocking(long duration,
TimeUnit timeUnit)
Blocking poll for the next entry which is timed out.
|
Map.Entry<K,V> |
pollTimeoutNow()
Nonblocking poll for the next entry which is timed out, based on the time of the invocation of this
method.
|
V |
put(long timeout,
K key,
V value)
Add a key-value pair with an associated timeout to the map.
|
V |
remove(K key)
removes an entry by it's key
|
int |
size()
query the number of entries in this map.
|
V put(long timeout, K key, V value)
timeout - the timeout for this key-value pair (in milliseconds)key - -value - -null if none.V get(K key)
key - null if the key does not exist.V remove(K key)
key - the key for which an entry must be removed.null if there was no entry for this key in that map, otherwise the value of the removed entry.Map.Entry<K,V> pollTimeoutNow()
null if there is no timed-out entry in this map. otherwise the oldest timed-out entry.List<Map.Entry<K,V>> pollAllTimeoutNow()
Collections.EMPTY_LIST if there is are no timed out entries in this map.Map.Entry<K,V> pollTimeoutBlocking() throws InterruptedException
null if there is no timed-out entry in this map within the given duration. otherwise the oldest
timed-out entry.InterruptedExceptionMap.Entry<K,V> pollTimeoutBlocking(long duration, TimeUnit timeUnit) throws InterruptedException
null if there is no timed-out entry in this map within the given duration. otherwise the oldest
timed-out entry.InterruptedExceptionvoid clear()
int size()
boolean isEmpty()
true if this map is empty, false otherwise.boolean containsKey(K key)
key - -true if there is an entry identified by that key in this map, false otherwise.long getTimeToNextTimeout()
Long.MAX_VALUE if the TimeoutMap is empty. Otherwise the time until the next entry
times out (in
milliseconds since the epoch). A return value of zero indicates that there is at least one entry which
has already timed out.Copyright © 2014. All Rights Reserved.