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