| Modifier and Type | Class and Description |
|---|---|
class |
Int2ObjectHashMap.EntryIterator
Iterator over entries which supports access to unboxed keys via
Int2ObjectHashMap.EntryIterator.getIntKey(). |
class |
Int2ObjectHashMap.EntrySet
Set of entries which supports access via an optionally cached iterator to avoid allocation.
|
class |
Int2ObjectHashMap.KeyIterator
Iterator over keys which supports access to unboxed keys via
Int2ObjectHashMap.KeyIterator.nextInt(). |
class |
Int2ObjectHashMap.KeySet
Set of keys which supports optionally cached iterators to avoid allocation.
|
class |
Int2ObjectHashMap.ValueCollection
Collection of values which supports optionally cached iterators to avoid allocation.
|
class |
Int2ObjectHashMap.ValueIterator
Iterator over values.
|
| Constructor and Description |
|---|
Int2ObjectHashMap()
Constructs map with
MIN_CAPACITY, Hashing.DEFAULT_LOAD_FACTOR and enables caching of iterators. |
Int2ObjectHashMap(Int2ObjectHashMap<V> mapToCopy)
Copy construct a new map from an existing one.
|
Int2ObjectHashMap(int initialCapacity,
float loadFactor)
Constructs map with given initial capacity and load factory and enables caching of iterators.
|
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 |
compute(Integer key,
BiFunction<? super Integer,? super V,? extends V> remappingFunction) |
V |
compute(int key,
IntObjectToObjectFunction<? 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(Integer key,
Function<? super Integer,? extends V> mappingFunction) |
V |
computeIfAbsent(int key,
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. |
V |
computeIfPresent(Integer key,
BiFunction<? super Integer,? super V,? extends V> remappingFunction) |
V |
computeIfPresent(int key,
IntObjectToObjectFunction<? 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 key)
Overloaded version of
Map.containsKey(Object) that takes a primitive int key. |
boolean |
containsKey(Object key) |
boolean |
containsValue(Object value) |
Int2ObjectHashMap.EntrySet |
entrySet() |
boolean |
equals(Object o) |
void |
forEach(BiConsumer<? super Integer,? super V> action) |
void |
forEachInt(IntObjConsumer<V> consumer)
Primitive specialised implementation of
Map.forEach(BiConsumer). |
V |
get(int key)
Overloaded version of
Map.get(Object) that takes a primitive int key. |
V |
get(Object key) |
protected V |
getMapped(int key)
Get mapped value without boxing the key.
|
V |
getOrDefault(int key,
V defaultValue)
Returns the value to which the specified key is mapped, or defaultValue if this map contains no mapping for the
key.
|
int |
hashCode() |
void |
intForEach(IntObjConsumer<V> consumer)
Deprecated.
Use
forEachInt(IntObjConsumer) instead. |
boolean |
isEmpty() |
Int2ObjectHashMap.KeySet |
keySet() |
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(Integer key,
V value,
BiFunction<? super V,? super V,? extends V> remappingFunction) |
V |
merge(int key,
V value,
BiFunction<? super V,? super V,? extends V> remappingFunction)
Primitive specialised version of
Map.merge(Object, Object, BiFunction). |
V |
put(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(Int2ObjectHashMap<? extends V> map)
Put all values from the given map into this one without allocation.
|
void |
putAll(Map<? extends Integer,? extends V> map) |
V |
putIfAbsent(int key,
V value)
Primitive specialised version of
Map.putIfAbsent(Object, Object). |
V |
remove(int key)
Overloaded version of
Map.remove(Object) that takes a primitive int key. |
boolean |
remove(int key,
V value)
Primitive specialised version of
Map.remove(Object, Object). |
V |
remove(Object key) |
boolean |
remove(Object key,
Object value) |
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) |
void |
replaceAll(BiFunction<? super Integer,? super V,? extends V> function) |
void |
replaceAllInt(IntObjectToObjectFunction<? super V,? extends V> function)
Primitive specialised version of
Map.replaceAll(BiFunction). |
int |
resizeThreshold()
Get the actual threshold which when reached the map will resize.
|
int |
size() |
String |
toString() |
protected V |
unmapNullValue(Object value)
Interceptor for unmasking null values.
|
Int2ObjectHashMap.ValueCollection |
values() |
clone, finalize, getClass, notify, notifyAll, wait, wait, waitgetOrDefault, putIfAbsent, replace, replacepublic Int2ObjectHashMap()
MIN_CAPACITY, Hashing.DEFAULT_LOAD_FACTOR and enables caching of iterators.public Int2ObjectHashMap(int initialCapacity,
float loadFactor)
initialCapacity - for the backing arrayloadFactor - limit for resizing on putspublic 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 void forEach(BiConsumer<? super Integer,? super V> action)
@Deprecated public void intForEach(IntObjConsumer<V> consumer)
forEachInt(IntObjConsumer) instead.forEachInt(IntObjConsumer) instead.consumer - a callback called for each key/value pair in the map.forEachInt(IntObjConsumer)public void forEachInt(IntObjConsumer<V> consumer)
Map.forEach(BiConsumer).
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<Integer,V>public boolean containsKey(int key)
Map.containsKey(Object) that takes a primitive int key.key - for indexing the Mappublic boolean containsValue(Object value)
containsValue in interface Map<Integer,V>public V get(int key)
Map.get(Object) that takes a primitive int key.key - for indexing the Map.public V getOrDefault(int key, V defaultValue)
key - whose associated value is to be returned.defaultValue - the default mapping of the key.defaultValue if this map contains no mapping for the key.protected V getMapped(int key)
key - to get value by.null.public V computeIfAbsent(Integer key, Function<? super Integer,? extends V> mappingFunction)
computeIfAbsent in interface Map<Integer,V>public V computeIfAbsent(int key, IntFunction<? extends V> mappingFunction)
IntFunction and put it in the map.
Primitive specialized version of Map.computeIfAbsent(Object, Function).
key - to search on.mappingFunction - to provide a value if the get returns null.public V computeIfPresent(Integer key, BiFunction<? super Integer,? super V,? extends V> remappingFunction)
computeIfPresent in interface Map<Integer,V>public V computeIfPresent(int key, IntObjectToObjectFunction<? super V,? extends V> remappingFunction)
If the function returns null, the mapping is removed.
Primitive specialized version of Map.computeIfPresent(Object, BiFunction).
key - to search on.remappingFunction - to provide a value if the get returns missingValue.null if none.public V compute(Integer key, BiFunction<? super Integer,? super V,? extends V> remappingFunction)
public V compute(int key, IntObjectToObjectFunction<? 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(Object, BiFunction).
key - to search on.remappingFunction - to provide a value if the get returns missingValue.null if none.public V merge(Integer key, V value, BiFunction<? super V,? super V,? extends V> remappingFunction)
public V merge(int key, V value, BiFunction<? super V,? super V,? extends V> remappingFunction)
Map.merge(Object, Object, BiFunction).key - with which the resulting value is to be associated.value - 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 key.remappingFunction - the function to recompute a value if present.public V put(int key, V value)
Map.put(Object, Object) that takes a primitive int key.public V remove(int key)
Map.remove(Object) that takes a primitive int key.key - for indexing the Map.public boolean remove(int key,
V value)
Map.remove(Object, Object).key - with which the specified value is associated.value - expected to be associated with the specified key.true if the value was removed.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(Int2ObjectHashMap<? extends V> map)
map - whose value are to be added.public V putIfAbsent(int key, V value)
Map.putIfAbsent(Object, Object).key - with which the specified value is to be associated.value - to be associated with the specified key.null if there was no mapping for the key.public Int2ObjectHashMap.KeySet keySet()
public Int2ObjectHashMap.ValueCollection values()
public Int2ObjectHashMap.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(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 replacedpublic void replaceAll(BiFunction<? super Integer,? super V,? extends V> function)
replaceAll in interface Map<Integer,V>public void replaceAllInt(IntObjectToObjectFunction<? super V,? extends V> function)
Map.replaceAll(BiFunction).
NB: Renamed from replaceAll to avoid overloading on parameter types of lambda expression, which doesn't play well with type inference in lambda expressions.
function - the function to apply to each entry.Copyright © 2014-2022 Real Logic Limited. All Rights Reserved.