Module org.apache.arrow.memory.core
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
ConstructorsConstructorDescriptionCreates a Map with default expected maximum size.LowCostIdentityHashMap(int maxSize) Creates a Map with the specified maximum size parameter. -
Method Summary
Modifier and TypeMethodDescriptionvoidclear()Removes all elements from this map, leaving it empty.booleancontainsKey(K key) Returns whether this map contains the specified key.booleancontainsValue(V value) Returns whether this map contains the specified value.@Nullable VReturns the value of the mapping with the specified key.@Nullable VSpecial API to return next value - substitute of regular Map.values.iterator().next().booleanisEmpty()Returns whether this Map has no elements.Maps the specified key to the specified value.@Nullable VRemoves the mapping with the specified key from this map.intsize()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:
trueif this map contains the specified key,falseotherwise.
-
containsValue
Returns whether this map contains the specified value.- Parameters:
value- the value to search for.- Returns:
trueif this map contains the specified value,falseotherwise.
-
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
nullif 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
nullif no mapping for the specified key was found.
-
isEmpty
public boolean isEmpty()Returns whether this Map has no elements.- Returns:
trueif this Map has no elements,falseotherwise.- 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
-