| Modifier and Type | Class and Description |
|---|---|
class |
Long2ObjectHashMap.EntryIterator
Iterator over entries which supports access to unboxed keys via
Long2ObjectHashMap.EntryIterator.getLongKey(). |
class |
Long2ObjectHashMap.EntrySet
Set of entries which supports access via an optionally cached iterator to avoid allocation.
|
class |
Long2ObjectHashMap.KeyIterator
Iterator over keys which supports access to unboxed keys via
Long2ObjectHashMap.KeyIterator.nextLong(). |
class |
Long2ObjectHashMap.KeySet
Set of keys which supports optionally cached iterators to avoid allocation.
|
class |
Long2ObjectHashMap.ValueCollection
Collection of values which supports optionally cached iterators to avoid allocation.
|
class |
Long2ObjectHashMap.ValueIterator
Iterator over values.
|
| Constructor and Description |
|---|
Long2ObjectHashMap()
Constructs map with
MIN_CAPACITY, Hashing.DEFAULT_LOAD_FACTOR and enables caching of iterators. |
Long2ObjectHashMap(int initialCapacity,
float loadFactor)
Constructs map with given initial capacity and load factory and enables caching of iterators.
|
Long2ObjectHashMap(int initialCapacity,
float loadFactor,
boolean shouldAvoidAllocation)
Construct a new map allowing a configuration for initial capacity and load factor.
|
Long2ObjectHashMap(Long2ObjectHashMap<V> mapToCopy)
Copy construct a new map from an existing one.
|
| Modifier and Type | Method and Description |
|---|---|
int |
capacity()
Get the total capacity for the map to which the load factor will be a fraction of.
|
void |
clear() |
void |
compact()
Compact the
Map backing arrays by rehashing with a capacity just larger than current size
and giving consideration to the load factor. |
V |
compute(long key,
LongObjectToObjectFunction<? 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(long key,
LongFunction<? extends V> mappingFunction)
Get a value for a given key, or if it does not exist then default the value
via a
LongFunction and put it in the map. |
V |
computeIfPresent(long key,
LongObjectToObjectFunction<? 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(long key)
Overloaded version of
Map.containsKey(Object) that takes a primitive long key. |
boolean |
containsKey(Object key) |
boolean |
containsValue(Object value) |
Long2ObjectHashMap.EntrySet |
entrySet() |
boolean |
equals(Object o) |
V |
get(long key)
Overloaded version of
Map.get(Object) that takes a primitive long key. |
V |
get(Object key) |
protected V |
getMapped(long key)
Get mapped value without boxing the key.
|
int |
hashCode() |
boolean |
isEmpty() |
Long2ObjectHashMap.KeySet |
keySet() |
float |
loadFactor()
Get the load factor beyond which the map will increase size.
|
void |
longForEach(LongObjConsumer<V> consumer)
Primitive specialised forEach implementation.
|
protected Object |
mapNullValue(Object value)
Longerceptor for masking null values.
|
V |
put(long key,
V value)
Overloaded version of
Map.put(Object, Object) that takes a primitive long key. |
V |
put(Long key,
V value) |
void |
putAll(Map<? extends Long,? extends V> map) |
V |
remove(long key)
Overloaded version of
Map.remove(Object) that takes a primitive long key. |
V |
remove(Object key) |
V |
replace(long key,
V value)
Primitive specialised version of
Map.replace(Object, Object) |
boolean |
replace(long key,
V oldValue,
V newValue)
Primitive specialised version of
Map.replace(Object, Object, Object) |
int |
resizeThreshold()
Get the actual threshold which when reached the map will resize.
|
int |
size() |
String |
toString() |
protected V |
unmapNullValue(Object value)
Longerceptor for unmasking null values.
|
Long2ObjectHashMap.ValueCollection |
values() |
clone, finalize, getClass, notify, notifyAll, wait, wait, waitcompute, computeIfAbsent, computeIfPresent, forEach, getOrDefault, merge, putIfAbsent, remove, replace, replace, replaceAllpublic Long2ObjectHashMap()
MIN_CAPACITY, Hashing.DEFAULT_LOAD_FACTOR and enables caching of iterators.public Long2ObjectHashMap(int initialCapacity,
float loadFactor)
initialCapacity - for the backing arrayloadFactor - limit for resizing on putspublic Long2ObjectHashMap(int initialCapacity,
float loadFactor,
boolean shouldAvoidAllocation)
initialCapacity - for the backing arrayloadFactor - limit for resizing on putsshouldAvoidAllocation - should allocation be avoided by caching iterators and map entries.public Long2ObjectHashMap(Long2ObjectHashMap<V> mapToCopy)
mapToCopy - for construction.public float loadFactor()
public int capacity()
public int resizeThreshold()
public void longForEach(LongObjConsumer<V> consumer)
NB: Renamed from forEach to avoid overloading on parameter types of lambda expression, which doesn't play well with type inference in lambda expressions.
consumer - a callback called for each key/value pair in the map.public boolean containsKey(Object key)
containsKey in interface Map<Long,V>public boolean containsKey(long key)
Map.containsKey(Object) that takes a primitive long key.key - for indexing the Mappublic boolean containsValue(Object value)
containsValue in interface Map<Long,V>public V get(long key)
Map.get(Object) that takes a primitive long key.key - for indexing the Map.protected V getMapped(long key)
key - to get value by.null.public V computeIfAbsent(long key, LongFunction<? extends V> mappingFunction)
LongFunction and put it in the map.
Primitive specialized version of Map.computeIfAbsent(K, java.util.function.Function<? super K, ? extends V>).
key - to search on.mappingFunction - to provide a value if the get returns null.public V computeIfPresent(long key, LongObjectToObjectFunction<? super V,? extends V> remappingFunction)
If the function returns null, the mapping is removed.
Primitive specialized version of Map.computeIfPresent(K, java.util.function.BiFunction<? super K, ? super V, ? extends V>).
key - to search on.remappingFunction - to provide a value if the get returns missingValue.null if none.public V compute(long key, LongObjectToObjectFunction<? super V,? extends V> remappingFunction)
null if there is no current mapping).
If the function returns null, the mapping is removed (or remains
absent if initially absent).
Primitive specialized version of Map.compute(K, java.util.function.BiFunction<? super K, ? super V, ? extends V>).
key - to search on.remappingFunction - to provide a value if the get returns missingValue.null if none.public V put(long key, V value)
Map.put(Object, Object) that takes a primitive long key.public V remove(long key)
Map.remove(Object) that takes a primitive long key.key - for indexing the Map.public void compact()
Map backing arrays by rehashing with a capacity just larger than current size
and giving consideration to the load factor.public Long2ObjectHashMap.KeySet keySet()
public Long2ObjectHashMap.ValueCollection values()
public Long2ObjectHashMap.EntrySet entrySet()
public boolean equals(Object o)
public int hashCode()
protected Object mapNullValue(Object value)
value - value to mask.protected V unmapNullValue(Object value)
value - value to unmask.public V replace(long key, V value)
Map.replace(Object, Object)key - key with which the specified value is associatedvalue - value to be associated with the specified keynull if there was no mapping for the key.public boolean replace(long key,
V oldValue,
V newValue)
Map.replace(Object, Object, Object)key - key with which the specified value is associatedoldValue - value expected to be associated with the specified keynewValue - value to be associated with the specified keytrue if the value was replacedCopyright © 2014-2022 Real Logic Limited. All Rights Reserved.