public class LongAdderTable<K> extends Object implements Serializable
LongAdder is associated with each key. Keys are added to
the table implicitly upon any attempt to update, or may be added
explicitly using method install(K).
jsr166e note: This class is targeted to be placed in java.util.concurrent.atomic.
| Constructor and Description |
|---|
LongAdderTable()
Creates a new empty table.
|
| Modifier and Type | Method and Description |
|---|---|
void |
add(K key,
long x)
Adds the given value to the sum associated with the given
key.
|
void |
decrement(K key)
Decrements the sum associated with the given key.
|
Set<Map.Entry<K,LongAdder>> |
entrySet()
Returns the current set of key-value mappings.
|
void |
increment(K key)
Increments the sum associated with the given key.
|
LongAdder |
install(K key)
If the given key does not already exist in the table, inserts
the key with initial sum of zero; in either case returning the
adder associated with this key.
|
Set<K> |
keySet()
Returns the current set of keys.
|
void |
remove(K key)
Removes the given key from the table.
|
void |
removeAll()
Removes all keys from the table.
|
void |
reset(K key)
Resets the sum associated with the given key to zero if the key
exists in the table.
|
void |
resetAll()
Resets the sum associated with each key to zero.
|
long |
sum(K key)
Returns the sum associated with the given key, or zero if the
key does not currently exist in the table.
|
long |
sumAll()
Returns the sum totalled across all keys.
|
long |
sumThenReset(K key)
Resets the sum associated with the given key to zero if the key
exists in the table.
|
long |
sumThenResetAll()
Totals, then resets, the sums associated with all keys.
|
public LongAdder install(K key)
key - the keypublic void add(K key, long x)
key - the keyx - the value to addpublic void increment(K key)
key - the keypublic void decrement(K key)
key - the keypublic long sum(K key)
key - the keypublic void reset(K key)
remove(K)).key - the keypublic long sumThenReset(K key)
remove(K)).key - the keypublic long sumAll()
public void resetAll()
public long sumThenResetAll()
public void remove(K key)
key - the keypublic void removeAll()
Copyright © 2013. All rights reserved.