K
- map key typepublic class DefaultAtomicCounterMap<K> extends Synchronous<AsyncAtomicCounterMap<K>> implements AtomicCounterMap<K>
AtomicCounterMap
.DistributedPrimitive.Status, DistributedPrimitive.Type
DEFAULT_OPERATION_TIMEOUT_MILLIS, DEFAULT_OPERTATION_TIMEOUT_MILLIS
Constructor and Description |
---|
DefaultAtomicCounterMap(AsyncAtomicCounterMap<K> asyncCounterMap,
long operationTimeoutMillis) |
Modifier and Type | Method and Description |
---|---|
long |
addAndGet(K key,
long delta)
Adds delta to the value currently associated with key, and returns the new value.
|
void |
clear()
Clears all entries from the map.
|
long |
decrementAndGet(K key)
Decrements by one the value currently associated with key, and returns the new value.
|
long |
get(K key)
Returns the value associated with key, or zero if there is no value associated with key.
|
long |
getAndAdd(K key,
long delta)
Adds delta to the value currently associated with key, and returns the old value.
|
long |
getAndDecrement(K key)
Decrements by one the value currently associated with key, and returns the old value.
|
long |
getAndIncrement(K key)
Increments by one the value currently associated with key, and returns the old value.
|
long |
incrementAndGet(K key)
Increments by one the value currently associated with key, and returns the new value.
|
boolean |
isEmpty()
If the map is empty, returns true, otherwise false.
|
long |
put(K key,
long newValue)
Associates ewValue with key in this map, and returns the value previously
associated with key, or zero if there was no such value.
|
long |
putIfAbsent(K key,
long newValue)
If key is not already associated with a value or if key is associated with
zero, associate it with newValue.
|
long |
remove(K key)
Removes and returns the value associated with key.
|
boolean |
remove(K key,
long value)
If (key, value) is currently in the map, this method removes it and returns
true; otherwise, this method returns false.
|
boolean |
replace(K key,
long expectedOldValue,
long newValue)
If (key, expectedOldValue) is currently in the map, this method replaces
expectedOldValue with newValue and returns true; otherwise, this method return false.
|
int |
size()
Returns the number of entries in the map.
|
destroy, name, primitiveType
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
primitiveType
addStatusChangeListener, applicationId, destroy, name, removeStatusChangeListener, statusChangeListeners
public DefaultAtomicCounterMap(AsyncAtomicCounterMap<K> asyncCounterMap, long operationTimeoutMillis)
public long incrementAndGet(K key)
AtomicCounterMap
incrementAndGet
in interface AtomicCounterMap<K>
key
- key with which the specified value is to be associatedpublic long decrementAndGet(K key)
AtomicCounterMap
decrementAndGet
in interface AtomicCounterMap<K>
key
- key with which the specified value is to be associatedpublic long getAndIncrement(K key)
AtomicCounterMap
getAndIncrement
in interface AtomicCounterMap<K>
key
- key with which the specified value is to be associatedpublic long getAndDecrement(K key)
AtomicCounterMap
getAndDecrement
in interface AtomicCounterMap<K>
key
- key with which the specified value is to be associatedpublic long addAndGet(K key, long delta)
AtomicCounterMap
addAndGet
in interface AtomicCounterMap<K>
key
- key with which the specified value is to be associateddelta
- the value to addpublic long getAndAdd(K key, long delta)
AtomicCounterMap
getAndAdd
in interface AtomicCounterMap<K>
key
- key with which the specified value is to be associateddelta
- the value to addpublic long get(K key)
AtomicCounterMap
get
in interface AtomicCounterMap<K>
key
- key with which the specified value is to be associatedpublic long put(K key, long newValue)
AtomicCounterMap
put
in interface AtomicCounterMap<K>
key
- key with which the specified value is to be associatednewValue
- the value to putpublic long putIfAbsent(K key, long newValue)
AtomicCounterMap
putIfAbsent
in interface AtomicCounterMap<K>
key
- key with which the specified value is to be associatednewValue
- the value to putpublic boolean replace(K key, long expectedOldValue, long newValue)
AtomicCounterMap
replace
in interface AtomicCounterMap<K>
key
- key with which the specified value is to be associatedexpectedOldValue
- the expected valuenewValue
- the value to replacepublic long remove(K key)
AtomicCounterMap
remove
in interface AtomicCounterMap<K>
key
- key with which the specified value is to be associatedpublic boolean remove(K key, long value)
AtomicCounterMap
remove
in interface AtomicCounterMap<K>
key
- key with which the specified value is to be associatedvalue
- the value to removepublic int size()
AtomicCounterMap
size
in interface AtomicCounterMap<K>
0
valuespublic boolean isEmpty()
AtomicCounterMap
isEmpty
in interface AtomicCounterMap<K>
public void clear()
AtomicCounterMap
clear
in interface AtomicCounterMap<K>