Package org.apache.arrow.memory
Class LowCostIdentityHashMap<K,V extends ValueWithKeyIncluded<K>>
java.lang.Object
org.apache.arrow.memory.LowCostIdentityHashMap<K,V>
- Type Parameters:
K
- Key typeV
- Value type
Highly specialized IdentityHashMap that implements only partial Map APIs. It incurs low initial
cost (just two elements by default). It assumes Value includes the Key -
Implements @ValueWithKeyIncluded iface that provides "getKey" method.
-
Constructor Summary
ConstructorDescriptionCreates a Map with default expected maximum size.LowCostIdentityHashMap
(int maxSize) Creates a Map with the specified maximum size parameter. -
Method Summary
Modifier and TypeMethodDescriptionvoid
clear()
Removes all elements from this map, leaving it empty.boolean
containsKey
(K key) Returns whether this map contains the specified key.boolean
containsValue
(V value) Returns whether this map contains the specified value.@Nullable V
Returns the value of the mapping with the specified key.@Nullable V
Special API to return next value - substitute of regular Map.values.iterator().next().boolean
isEmpty()
Returns whether this Map has no elements.Maps the specified key to the specified value.@Nullable V
Removes the mapping with the specified key from this map.int
size()
Returns the number of mappings in this Map.
-
Constructor Details
-
LowCostIdentityHashMap
public LowCostIdentityHashMap()Creates a Map with default expected maximum size. -
LowCostIdentityHashMap
public LowCostIdentityHashMap(int maxSize) Creates a Map with the specified maximum size parameter.- Parameters:
maxSize
- The estimated maximum number of entries that will be put in this map.
-
-
Method Details
-
clear
public void clear()Removes all elements from this map, leaving it empty. -
containsKey
Returns whether this map contains the specified key.- Parameters:
key
- the key to search for.- Returns:
true
if this map contains the specified key,false
otherwise.
-
containsValue
Returns whether this map contains the specified value.- Parameters:
value
- the value to search for.- Returns:
true
if this map contains the specified value,false
otherwise.
-
get
Returns the value of the mapping with the specified key.- Parameters:
key
- the key.- Returns:
- the value of the mapping with the specified key.
-
put
Maps the specified key to the specified value.- Parameters:
value
- the value.- Returns:
- the value of any previous mapping with the specified key or
null
if there was no such mapping.
-
remove
Removes the mapping with the specified key from this map.- Parameters:
key
- the key of the mapping to remove.- Returns:
- the value of the removed mapping, or
null
if no mapping for the specified key was found.
-
isEmpty
public boolean isEmpty()Returns whether this Map has no elements.- Returns:
true
if this Map has no elements,false
otherwise.- See Also:
-
size
public int size()Returns the number of mappings in this Map.- Returns:
- the number of mappings in this Map.
-
getNextValue
Special API to return next value - substitute of regular Map.values.iterator().next().- Returns:
- next available value or null if none available
-