V - type of the object stored in the map.public class BiInt2ObjectMap<V> extends Object
| Modifier and Type | Class and Description |
|---|---|
static interface |
BiInt2ObjectMap.EntryConsumer<V>
Handler for a map entry
|
static interface |
BiInt2ObjectMap.EntryFunction<V>
Creates a new value based upon keys.
|
static interface |
BiInt2ObjectMap.EntryRemap<V,V1>
Creates a new value based upon keys.
|
| Constructor and Description |
|---|
BiInt2ObjectMap()
Construct an empty map.
|
BiInt2ObjectMap(int initialCapacity,
float loadFactor)
Construct a map that sets it initial capacity and load factor.
|
| Modifier and Type | Method and Description |
|---|---|
int |
capacity()
Get the total capacity for the map to which the load factor with be a fraction of.
|
void |
clear()
Clear out the map of 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.
|
V |
compute(int keyPartA,
int keyPartB,
BiInt2ObjectMap.EntryRemap<? super V,? extends V> remappingFunction)
Attempts to compute a mapping for the specified key and its current mapped value (or null if there is no current
mapping).
|
V |
computeIfAbsent(int keyPartA,
int keyPartB,
BiInt2ObjectMap.EntryFunction<? extends V> mappingFunction)
If the specified key is not already associated with a value (or is mapped
to
null), attempts to compute its value using the given mapping
function and enters it into this map unless null. |
V |
computeIfPresent(int keyPartA,
int keyPartB,
BiInt2ObjectMap.EntryRemap<? super V,? extends V> remappingFunction)
If the value for the specified key is present and non-null, attempts to compute a new mapping given the key and
its current mapped value.
|
boolean |
containsKey(int keyPartA,
int keyPartB)
Returns true if this map contains a mapping for the specified key.
|
void |
forEach(BiInt2ObjectMap.EntryConsumer<V> consumer)
Iterate over the contents of the map
|
void |
forEach(Consumer<V> consumer)
Iterate over the contents of the map
|
V |
get(int keyPartA,
int keyPartB)
Retrieve a value from the map.
|
V |
getOrDefault(int keyPartA,
int keyPartB,
V defaultValue)
Retrieve a value from the map or
defaultValue if this map contains not mapping for the key. |
boolean |
isEmpty()
Is map empty or not.
|
float |
loadFactor()
Get the load factor beyond which the map will increase size.
|
protected Object |
mapNullValue(Object value)
Interceptor for masking null values.
|
V |
merge(int keyPartA,
int keyPartB,
V value,
BiFunction<? super V,? super V,? extends V> remappingFunction)
If the specified key is not already associated with a value or is associated with null, associates it with the
given non-null value.
|
V |
put(int keyPartA,
int keyPartB,
V value)
Put a value into the map.
|
V |
putIfAbsent(int keyPartA,
int keyPartB,
V value)
If the specified key is not already associated with a value (or is mapped to null) associates it with the given
value and returns null, else returns the current value.
|
V |
remove(int keyPartA,
int keyPartB)
Remove a value from the map and return the value.
|
boolean |
remove(int keyPartA,
int keyPartB,
V value)
Removes the entry for the specified key only if it is currently mapped to the specified value.
|
V |
replace(int keyPartA,
int keyPartB,
V value)
Replaces the entry for the specified key only if currently mapped to the specified value.
|
boolean |
replace(int keyPartA,
int keyPartB,
V oldValue,
V newValue)
Replaces the entry for the specified key only if currently mapped to the specified value.
|
int |
resizeThreshold()
Get the actual threshold which when reached the map will resize.
|
int |
size()
Return the number of unique entries in the map.
|
String |
toString() |
protected V |
unmapNullValue(Object value)
Interceptor for unmasking null values.
|
public BiInt2ObjectMap()
public BiInt2ObjectMap(int initialCapacity,
float loadFactor)
initialCapacity - for the underlying hash maploadFactor - for the underlying hash mappublic int capacity()
public float loadFactor()
public int resizeThreshold()
public void clear()
Map.clear()public void compact()
public V put(int keyPartA, int keyPartB, V value)
keyPartA - for the keykeyPartB - for the keyvalue - to put into the mapMap.put(Object, Object)protected Object mapNullValue(Object value)
value - value to mask.protected V unmapNullValue(Object value)
value - value to unmask.public V get(int keyPartA, int keyPartB)
keyPartA - for the keykeyPartB - for the keyMap.get(Object)public V getOrDefault(int keyPartA, int keyPartB, V defaultValue)
defaultValue if this map contains not mapping for the key.keyPartA - for the keykeyPartB - for the keydefaultValue - the default mapping of the keydefaultValue if not found.Map.getOrDefault(Object, Object)public boolean containsKey(int keyPartA,
int keyPartB)
keyPartA - for the keykeyPartB - for the keytrue if this map contains a mapping for the specified keyMap.containsKey(Object)public V remove(int keyPartA, int keyPartB)
keyPartA - for the keykeyPartB - for the keyMap.remove(Object)public V computeIfAbsent(int keyPartA, int keyPartB, BiInt2ObjectMap.EntryFunction<? extends V> mappingFunction)
null), attempts to compute its value using the given mapping
function and enters it into this map unless null.keyPartA - for the keykeyPartB - for the keymappingFunction - creates values based upon keys if the key pair is missingMap.computeIfAbsent(Object, Function)public V computeIfPresent(int keyPartA, int keyPartB, BiInt2ObjectMap.EntryRemap<? super V,? extends V> remappingFunction)
If the function returns null, the mapping is removed. If the function itself throws an (unchecked) exception, the exception is rethrown, and the current mapping is left unchanged.
keyPartA - for the keykeyPartB - for the keyremappingFunction - the function to compute a valueMap.computeIfPresent(Object, BiFunction)public V compute(int keyPartA, int keyPartB, BiInt2ObjectMap.EntryRemap<? super V,? extends V> remappingFunction)
keyPartA - for the keykeyPartB - for the keyremappingFunction - the function to compute a valueMap.compute(Object, BiFunction)public V merge(int keyPartA, int keyPartB, V value, BiFunction<? super V,? super V,? extends V> remappingFunction)
keyPartA - for the keykeyPartB - for the keyvalue - the non-null value to be merged with the existing value associated with the key or, if
no existing value or a null value is associated with the key, to be associated with the
keyremappingFunction - the function to recompute a value if presentMap.merge(Object, Object, BiFunction)public void forEach(Consumer<V> consumer)
consumer - to apply to each value in the mappublic void forEach(BiInt2ObjectMap.EntryConsumer<V> consumer)
consumer - to apply to each value in the mappublic V replace(int keyPartA, int keyPartB, V value)
keyPartA - for the keykeyPartB - for the keyvalue - value to be associated with the specified keyMap.replace(Object, Object)public boolean replace(int keyPartA,
int keyPartB,
V oldValue,
V newValue)
keyPartA - for the keykeyPartB - for the keyoldValue - value expected to be associated with the specified keynewValue - to be associated with the specified keypublic V putIfAbsent(int keyPartA, int keyPartB, V value)
keyPartA - for the keykeyPartB - for the keyvalue - to put into the mappublic boolean remove(int keyPartA,
int keyPartB,
V value)
keyPartA - for the keykeyPartB - for the keyvalue - value expected to be associated with the specified keyMap.remove(Object, Object)public int size()
public boolean isEmpty()
Copyright © 2014-2022 Real Logic Limited. All Rights Reserved.