public class Int2IntCounterMap extends Object implements Serializable
initialValue
as deleted. This means that changing a counter may impact size()
.Constructor and Description |
---|
Int2IntCounterMap(int initialValue)
Construct a new counter map with the initial value for the counter provided.
|
Int2IntCounterMap(int initialCapacity,
float loadFactor,
int initialValue) |
Modifier and Type | Method and Description |
---|---|
int |
addAndGet(int 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(int key,
IntUnaryOperator mappingFunction)
Try get a value for a key and if not present then apply mapping function.
|
boolean |
containsKey(int 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(int key)
Convenience version of
addAndGet(int, int) (key, -1). |
void |
forEach(IntIntConsumer consumer)
Iterate over all value in the map which are not at
initialValue() . |
int |
get(int key)
Get the value of a counter associated with a key or
initialValue() if not found. |
int |
getAndAdd(int key,
int amount)
Add amount to the current value associated with this key.
|
int |
getAndDecrement(int key)
Convenience version of
getAndAdd(int, int) (key, -1). |
int |
getAndIncrement(int key)
Convenience version of
getAndAdd(int, int) (key, 1). |
int |
incrementAndGet(int key)
Convenience version of
addAndGet(int, 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(int key,
int value)
Put the value for a key in the map.
|
int |
remove(int 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 Int2IntCounterMap(int initialValue)
initialValue
- to be used for each counter.public Int2IntCounterMap(int initialCapacity, float loadFactor, int initialValue)
public int initialValue()
public float loadFactor()
public int resizeThreshold()
public int capacity()
public int size()
initialValue()
.initialValue()
are not countedpublic boolean isEmpty()
public int get(int key)
initialValue()
if not found.key
- lookup keyinitialValue()
if not found.public int put(int key, int value)
key
- lookup keyvalue
- new value, must not be initialValueinitialValue()
if none foundIllegalArgumentException
- if value is initialValue()
public int incrementAndGet(int key)
addAndGet(int, int)
(key, 1).key
- for the counter.public int decrementAndGet(int key)
addAndGet(int, int)
(key, -1).key
- for the counter.public int addAndGet(int 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 existingamount
- to be addedinitialValue()
+ amount if there was no mapping for the key.public int getAndIncrement(int key)
getAndAdd(int, int)
(key, 1).key
- for the counter.public int getAndDecrement(int key)
getAndAdd(int, int)
(key, -1).key
- for the counter.public int getAndAdd(int 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 existingamount
- to be addedinitialValue()
if there was no mapping for the key.public void forEach(IntIntConsumer consumer)
initialValue()
.consumer
- called for each key/value pair in the map.public boolean containsKey(int 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(int key, IntUnaryOperator mappingFunction)
key
- to search on.mappingFunction
- to provide a value if the get returns null.public int remove(int key)
key
- to be removedpublic int minValue()
initialValue()
public int maxValue()
initialValue()
Copyright © 2014-2020 Real Logic Limited. All Rights Reserved.