Package org.agrona.collections
Class Object2NullableObjectHashMap<K,V>
java.lang.Object
org.agrona.collections.Object2ObjectHashMap<K,V>
org.agrona.collections.Object2NullableObjectHashMap<K,V>
- Type Parameters:
K
- the type of keys maintained by this map.V
- the type of mapped values.
- All Implemented Interfaces:
Map<K,
V>
Variation of
Object2ObjectHashMap
that allows null
values.-
Nested Class Summary
Nested classes/interfaces inherited from class org.agrona.collections.Object2ObjectHashMap
Object2ObjectHashMap.AbstractIterator, Object2ObjectHashMap.EntryIterator, Object2ObjectHashMap.EntrySet, Object2ObjectHashMap.KeyIterator, Object2ObjectHashMap.KeySet, Object2ObjectHashMap.ValueCollection, Object2ObjectHashMap.ValueIterator
-
Field Summary
Fields inherited from class org.agrona.collections.Object2ObjectHashMap
MIN_CAPACITY
-
Constructor Summary
ConstructorsConstructorDescriptionDefault constructor.Object2NullableObjectHashMap
(int initialCapacity, float loadFactor) Defaults to avoiding allocation.Object2NullableObjectHashMap
(int initialCapacity, float loadFactor, boolean shouldAvoidAllocation) Create a new instance with specified parameters.Object2NullableObjectHashMap
(Object2ObjectHashMap<K, V> mapToCopy) Copy construct a new map from an existing one. -
Method Summary
Modifier and TypeMethodDescriptionprotected Object
mapNullValue
(Object value) Handle incoming null value and optionally replace with another non-null counterpart.protected V
unmapNullValue
(Object value) Handle incoming non-null value and optionally replace it with the null value counterpart.Methods inherited from class org.agrona.collections.Object2ObjectHashMap
capacity, clear, compact, compute, computeIfAbsent, computeIfPresent, containsKey, containsValue, entrySet, equals, forEach, get, hashCode, isEmpty, keySet, loadFactor, put, putAll, remove, resizeThreshold, size, toString, values
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.util.Map
getOrDefault, merge, putIfAbsent, remove, replace, replace, replaceAll
-
Constructor Details
-
Object2NullableObjectHashMap
public Object2NullableObjectHashMap()Default constructor. -
Object2NullableObjectHashMap
public Object2NullableObjectHashMap(int initialCapacity, float loadFactor) Defaults to avoiding allocation.- Parameters:
initialCapacity
- for the map to overrideObject2ObjectHashMap.MIN_CAPACITY
loadFactor
- for the map to overrideHashing.DEFAULT_LOAD_FACTOR
.
-
Object2NullableObjectHashMap
public Object2NullableObjectHashMap(int initialCapacity, float loadFactor, boolean shouldAvoidAllocation) Create a new instance with specified parameters.- Parameters:
initialCapacity
- for the map to overrideObject2ObjectHashMap.MIN_CAPACITY
loadFactor
- for the map to overrideHashing.DEFAULT_LOAD_FACTOR
.shouldAvoidAllocation
- should allocation be avoided by caching iterators and map entries.
-
Object2NullableObjectHashMap
Copy construct a new map from an existing one.- Parameters:
mapToCopy
- for construction.
-
-
Method Details
-
mapNullValue
Description copied from class:Object2ObjectHashMap
Handle incoming null value and optionally replace with another non-null counterpart.- Overrides:
mapNullValue
in classObject2ObjectHashMap<K,
V> - Parameters:
value
- value to be handled.- Returns:
- replacement value.
-
unmapNullValue
Description copied from class:Object2ObjectHashMap
Handle incoming non-null value and optionally replace it with the null value counterpart. This is the opposite of theObject2ObjectHashMap.mapNullValue(Object)
method.- Overrides:
unmapNullValue
in classObject2ObjectHashMap<K,
V> - Parameters:
value
- value to be handled.- Returns:
- replacement value.
- See Also:
-