public class Object2IntCounterMap<K> extends Object
initialValue as deleted.
This means that changing a counter may impact size().| Constructor and Description |
|---|
Object2IntCounterMap(int initialValue)
Construct a new counter map with the initial value for the counter provided.
|
Object2IntCounterMap(int initialCapacity,
float loadFactor,
int initialValue)
Construct a new counter map with the initial value for the counter provided.
|
| Modifier and Type | Method and Description |
|---|---|
int |
addAndGet(K key,
int 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.
|
int |
computeIfAbsent(K key,
ToIntFunction<? 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(int value)
Iterate over the values to see if any match the provided value.
|
int |
decrementAndGet(K key)
Convenience version of
addAndGet(Object, int) (key, -1). |
void |
forEach(ObjIntConsumer<K> consumer)
Iterate over all value in the map which are not at
initialValue(). |
int |
get(K key)
Get the value of a counter associated with a key or
initialValue() if not found. |
int |
getAndAdd(K key,
int amount)
Add amount to the current value associated with this key.
|
int |
getAndDecrement(K key)
Convenience version of
getAndAdd(Object, int) (key, -1). |
int |
getAndIncrement(K key)
Convenience version of
getAndAdd(Object, int) (key, 1). |
int |
incrementAndGet(K key)
Convenience version of
addAndGet(Object, int) (key, 1). |
int |
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.
|
int |
maxValue()
Get the maximum value stored in the map.
|
int |
minValue()
Get the minimum value stored in the map.
|
int |
put(K key,
int value)
Put the value for a key in the map.
|
int |
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 Object2IntCounterMap(int initialValue)
initialValue - to be used for each counter.public Object2IntCounterMap(int initialCapacity,
float loadFactor,
int initialValue)
initialCapacity - of the map.loadFactor - applied for resize operations.initialValue - to be used for each counter.public int initialValue()
public float loadFactor()
public int resizeThreshold()
public int capacity()
public int size()
initialValue().initialValue() are not counted.public boolean isEmpty()
public int get(K key)
initialValue() if not found.key - lookup key.initialValue() if not found.public int put(K key, int value)
key - lookup key.value - new value, must not be initialValue.initialValue() if none found.IllegalArgumentException - if value is initialValue().public int incrementAndGet(K key)
addAndGet(Object, int) (key, 1).key - for the counter.public int decrementAndGet(K key)
addAndGet(Object, int) (key, -1).key - for the counter.public int addAndGet(K key, int 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 int getAndIncrement(K key)
getAndAdd(Object, int) (key, 1).key - for the counter.public int getAndDecrement(K key)
getAndAdd(Object, int) (key, -1).key - for the counter.public int getAndAdd(K key, int 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(ObjIntConsumer<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(int value)
If value provided is initialValue() then it will always return false.
value - the key to check.public void clear()
public void compact()
public int computeIfAbsent(K key, ToIntFunction<? 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 int remove(K key)
key - to be removed.public int minValue()
initialValue()public int maxValue()
initialValue()Copyright © 2014-2022 Real Logic Limited. All Rights Reserved.