public class Object2LongCounterMap<K> extends Object
initialValue as deleted.
This means that changing a counter may impact size().| Constructor and Description |
|---|
Object2LongCounterMap(int initialCapacity,
float loadFactor,
long initialValue)
Construct a new counter map with the initial value for the counter provided.
|
Object2LongCounterMap(long initialValue)
Construct a new counter map with the initial value for the counter provided.
|
| Modifier and Type | Method and Description |
|---|---|
long |
addAndGet(K key,
long amount)
Add amount to the current value associated with this key.
|
int |
capacity()
Get the total capacity for the map to which the load factor will be a fraction of.
|
void |
clear()
Clear out all entries.
|
void |
compact()
Compact the backing arrays by rehashing with a capacity just larger than current size
and giving consideration to the load factor.
|
long |
computeIfAbsent(K key,
ToLongFunction<? super K> mappingFunction)
Try
get(Object) a value for a key and if not present then apply mapping function. |
boolean |
containsKey(K key)
Does the map contain a value for a given key which is not
initialValue(). |
boolean |
containsValue(long value)
Iterate over the values to see if any match the provided value.
|
long |
decrementAndGet(K key)
Convenience version of
addAndGet(Object, long) (key, -1). |
void |
forEach(ObjLongConsumer<K> consumer)
Iterate over all value in the map which are not at
initialValue(). |
long |
get(K key)
Get the value of a counter associated with a key or
initialValue() if not found. |
long |
getAndAdd(K key,
long amount)
Add amount to the current value associated with this key.
|
long |
getAndDecrement(K key)
Convenience version of
getAndAdd(Object, long) (key, -1). |
long |
getAndIncrement(K key)
Convenience version of
getAndAdd(Object, long) (key, 1). |
long |
incrementAndGet(K key)
Convenience version of
addAndGet(Object, long) (key, 1). |
long |
initialValue()
The value to be used as a null marker in the map.
|
boolean |
isEmpty()
Is the map empty.
|
float |
loadFactor()
Get the load factor applied for resize operations.
|
long |
maxValue()
Get the maximum value stored in the map.
|
long |
minValue()
Get the minimum value stored in the map.
|
long |
put(K key,
long value)
Put the value for a key in the map.
|
long |
remove(K key)
Remove a counter value for a given key.
|
int |
resizeThreshold()
Get the actual threshold which when reached the map will resize.
|
int |
size()
The current size of the map which at not at
initialValue(). |
String |
toString() |
public Object2LongCounterMap(long initialValue)
initialValue - to be used for each counter.public Object2LongCounterMap(int initialCapacity,
float loadFactor,
long initialValue)
initialCapacity - of the map.loadFactor - applied for resize operations.initialValue - to be used for each counter.public long initialValue()
public float loadFactor()
public int resizeThreshold()
public int capacity()
public int size()
initialValue().initialValue() are not counted.public boolean isEmpty()
public long get(K key)
initialValue() if not found.key - lookup key.initialValue() if not found.public long put(K key, long value)
key - lookup key.value - new value, must not be initialValue.initialValue() if none found.IllegalArgumentException - if value is initialValue().public long incrementAndGet(K key)
addAndGet(Object, long) (key, 1).key - for the counter.public long decrementAndGet(K key)
addAndGet(Object, long) (key, -1).key - for the counter.public long addAndGet(K key, long amount)
initialValue() as
current value and associate key with initialValue() + amount unless amount is 0, in which case map
remains unchanged.key - new or existing.amount - to be added.initialValue() + amount if there was no mapping for the key.public long getAndIncrement(K key)
getAndAdd(Object, long) (key, 1).key - for the counter.public long getAndDecrement(K key)
getAndAdd(Object, long) (key, -1).key - for the counter.public long getAndAdd(K key, long amount)
initialValue() as
current value and associate key with initialValue() + amount unless amount is 0, in which case map
remains unchanged.key - new or existing.amount - to be added.initialValue() if there was no mapping for the key.public void forEach(ObjLongConsumer<K> consumer)
initialValue().consumer - called for each key/value pair in the map.public boolean containsKey(K key)
initialValue().key - the key to check.initialValue(), false otherwise.public boolean containsValue(long value)
If value provided is initialValue() then it will always return false.
value - the key to check.public void clear()
public void compact()
public long computeIfAbsent(K key, ToLongFunction<? super K> mappingFunction)
get(Object) a value for a key and if not present then apply mapping function.key - to search on.mappingFunction - to provide a value if the get returns null.public long remove(K key)
key - to be removed.public long minValue()
initialValue()public long maxValue()
initialValue()Copyright © 2014-2022 Real Logic Limited. All Rights Reserved.