K
- type of keys stored in the Map
public class Object2LongHashMap<K> extends Object implements Map<K,Long>
Map
implementation specialised for long values using open addressing and
linear probing for cache efficient access. The implementation is mirror copy of Long2ObjectHashMap
and it also relies on missing value concept from Long2LongHashMap
Modifier and Type | Class and Description |
---|---|
class |
Object2LongHashMap.EntryIterator |
class |
Object2LongHashMap.EntrySet |
class |
Object2LongHashMap.KeyIterator |
class |
Object2LongHashMap.KeySet |
class |
Object2LongHashMap.ValueCollection |
class |
Object2LongHashMap.ValueIterator |
Constructor and Description |
---|
Object2LongHashMap(int initialCapacity,
float loadFactor,
long missingValue)
Construct a new map allowing a configuration for initial capacity and load factor.
|
Object2LongHashMap(int initialCapacity,
float loadFactor,
long missingValue,
boolean shouldAvoidAllocation)
Construct a new map allowing a configuration for initial capacity and load factor.
|
Object2LongHashMap(long missingValue)
Construct a map with default capacity and load factor.
|
Object2LongHashMap(Object2LongHashMap<K> 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. |
boolean |
containsKey(Object key)
Overloaded version of
Map.containsKey(Object) that takes a primitive long key. |
boolean |
containsValue(long value) |
boolean |
containsValue(Object value) |
Object2LongHashMap.EntrySet |
entrySet() |
boolean |
equals(Object o) |
Long |
get(Object key) |
long |
getValue(K key)
Overloaded version of
Map.get(Object) that takes a primitive long key. |
int |
hashCode() |
boolean |
isEmpty() |
Object2LongHashMap.KeySet |
keySet() |
float |
loadFactor()
Get the load factor beyond which the map will increase size.
|
long |
missingValue()
The value to be used as a null marker in the map.
|
long |
put(K key,
long value)
Overloaded version of
Map.put(Object, Object) that takes a primitive long key. |
Long |
put(K key,
Long value) |
void |
putAll(Map<? extends K,? extends Long> map) |
Long |
remove(Object key) |
long |
removeKey(K key)
Overloaded version of
Map.remove(Object) that takes a primitive long key. |
long |
replace(K key,
long value)
Primitive specialised version of
Map.replace(Object, Object) |
boolean |
replace(K key,
long oldValue,
long 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() |
Object2LongHashMap.ValueCollection |
values() |
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
compute, computeIfAbsent, computeIfPresent, forEach, getOrDefault, merge, putIfAbsent, remove, replace, replace, replaceAll
public Object2LongHashMap(long missingValue)
missingValue
- value to be used as a null maker in the mappublic Object2LongHashMap(int initialCapacity, float loadFactor, long missingValue)
initialCapacity
- for the backing arrayloadFactor
- limit for resizing on putsmissingValue
- value to be used as a null marker in the mappublic Object2LongHashMap(int initialCapacity, float loadFactor, long missingValue, boolean shouldAvoidAllocation)
initialCapacity
- for the backing arrayloadFactor
- limit for resizing on putsmissingValue
- value to be used as a null marker in the mapshouldAvoidAllocation
- should allocation be avoided by caching iterators and map entries.public Object2LongHashMap(Object2LongHashMap<K> mapToCopy)
mapToCopy
- for construction.public long missingValue()
public float loadFactor()
public int capacity()
public int resizeThreshold()
public boolean containsKey(Object key)
Map.containsKey(Object)
that takes a primitive long key.containsKey
in interface Map<K,Long>
key
- for indexing the Map
public boolean containsValue(Object value)
containsValue
in interface Map<K,Long>
public boolean containsValue(long value)
public long getValue(K key)
Map.get(Object)
that takes a primitive long key.
Due to type erasure have to rename the methodkey
- for indexing the Map
public long put(K key, long value)
Map.put(Object, Object)
that takes a primitive long key.public long removeKey(K key)
Map.remove(Object)
that takes a primitive long key.
Due to type erasure have to rename the methodkey
- 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 Object2LongHashMap.KeySet keySet()
public Object2LongHashMap.ValueCollection values()
public Object2LongHashMap.EntrySet entrySet()
public boolean equals(Object o)
public int hashCode()
public long replace(K key, long 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(K key, long oldValue, long 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 © 2022 Hazelcast, Inc.. All Rights Reserved.