V
- type of values stored in the Map
public class Int2ObjectHashMap<V>
extends java.lang.Object
implements java.util.Map<java.lang.Integer,V>, java.io.Serializable
Map
implementation specialised for int keys using open addressing and
linear probing for cache efficient access.Modifier and Type | Class and Description |
---|---|
class |
Int2ObjectHashMap.EntryIterator |
class |
Int2ObjectHashMap.EntrySet |
class |
Int2ObjectHashMap.KeyIterator |
class |
Int2ObjectHashMap.KeySet |
class |
Int2ObjectHashMap.ValueCollection |
class |
Int2ObjectHashMap.ValueIterator |
Constructor and Description |
---|
Int2ObjectHashMap() |
Int2ObjectHashMap(Int2ObjectHashMap<V> mapToCopy)
Copy construct a new map from an existing one.
|
Int2ObjectHashMap(int initialCapacity,
float loadFactor) |
Int2ObjectHashMap(int initialCapacity,
float loadFactor,
boolean shouldAvoidAllocation)
Construct a new map allowing a configuration for 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 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 |
computeIfAbsent(int key,
java.util.function.IntFunction<? extends V> mappingFunction)
Get a value for a given key, or if it does not exist then default the value via a
IntFunction and put it in the map. |
boolean |
containsKey(int key)
Overloaded version of
Map.containsKey(Object) that takes a primitive int key. |
boolean |
containsKey(java.lang.Object key) |
boolean |
containsValue(java.lang.Object value) |
Int2ObjectHashMap.EntrySet |
entrySet() |
boolean |
equals(java.lang.Object o) |
V |
get(int key)
Overloaded version of
Map.get(Object) that takes a primitive int key. |
V |
get(java.lang.Object key) |
protected V |
getMapped(int key) |
int |
hashCode() |
boolean |
isEmpty() |
Int2ObjectHashMap.KeySet |
keySet() |
float |
loadFactor()
Get the load factor beyond which the map will increase size.
|
protected java.lang.Object |
mapNullValue(java.lang.Object value) |
V |
put(java.lang.Integer key,
V value) |
V |
put(int key,
V value)
Overloaded version of
Map.put(Object, Object) that takes a primitive int key. |
void |
putAll(java.util.Map<? extends java.lang.Integer,? extends V> map) |
V |
remove(int key)
Overloaded version of
Map.remove(Object) that takes a primitive int key. |
V |
remove(java.lang.Object key) |
V |
replace(int key,
V value)
Primitive specialised version of
Map.replace(Object, Object) |
boolean |
replace(int 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() |
java.lang.String |
toString() |
protected V |
unmapNullValue(java.lang.Object value) |
Int2ObjectHashMap.ValueCollection |
values() |
public Int2ObjectHashMap()
public Int2ObjectHashMap(int initialCapacity, float loadFactor)
public Int2ObjectHashMap(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 Int2ObjectHashMap(Int2ObjectHashMap<V> mapToCopy)
mapToCopy
- for construction.public float loadFactor()
public int capacity()
public int resizeThreshold()
public int size()
size
in interface java.util.Map<java.lang.Integer,V>
public boolean isEmpty()
isEmpty
in interface java.util.Map<java.lang.Integer,V>
public boolean containsKey(java.lang.Object key)
containsKey
in interface java.util.Map<java.lang.Integer,V>
public boolean containsKey(int key)
Map.containsKey(Object)
that takes a primitive int key.key
- for indexing the Map
public boolean containsValue(java.lang.Object value)
containsValue
in interface java.util.Map<java.lang.Integer,V>
public V get(java.lang.Object key)
get
in interface java.util.Map<java.lang.Integer,V>
public V get(int key)
Map.get(Object)
that takes a primitive int key.key
- for indexing the Map
protected V getMapped(int key)
public V computeIfAbsent(int key, java.util.function.IntFunction<? extends V> mappingFunction)
IntFunction
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 put(java.lang.Integer key, V value)
put
in interface java.util.Map<java.lang.Integer,V>
public V put(int key, V value)
Map.put(Object, Object)
that takes a primitive int key.key
- for indexing the Map
value
- to be inserted in the Map
public V remove(java.lang.Object key)
remove
in interface java.util.Map<java.lang.Integer,V>
public V remove(int key)
Map.remove(Object)
that takes a primitive int key.key
- for indexing the Map
public void clear()
clear
in interface java.util.Map<java.lang.Integer,V>
public void compact()
Map
backing arrays by rehashing with a capacity just larger than current size
and giving consideration to the load factor.public void putAll(java.util.Map<? extends java.lang.Integer,? extends V> map)
putAll
in interface java.util.Map<java.lang.Integer,V>
public Int2ObjectHashMap.KeySet keySet()
keySet
in interface java.util.Map<java.lang.Integer,V>
public Int2ObjectHashMap.ValueCollection values()
values
in interface java.util.Map<java.lang.Integer,V>
public Int2ObjectHashMap.EntrySet entrySet()
entrySet
in interface java.util.Map<java.lang.Integer,V>
public java.lang.String toString()
toString
in class java.lang.Object
public boolean equals(java.lang.Object o)
equals
in interface java.util.Map<java.lang.Integer,V>
equals
in class java.lang.Object
public int hashCode()
hashCode
in interface java.util.Map<java.lang.Integer,V>
hashCode
in class java.lang.Object
protected java.lang.Object mapNullValue(java.lang.Object value)
protected V unmapNullValue(java.lang.Object value)
public V replace(int 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(int 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-2019 Real Logic Ltd. All Rights Reserved.