Class LowCostIdentityHashMap<K,V extends ValueWithKeyIncluded<K>>

java.lang.Object
org.apache.arrow.memory.LowCostIdentityHashMap<K,V>
Type Parameters:
K - Key type
V - Value type

public class LowCostIdentityHashMap<K,V extends ValueWithKeyIncluded<K>> extends Object
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

    Constructors
    Constructor
    Description
    Creates a Map with default expected maximum size.
    Creates a Map with the specified maximum size parameter.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Removes all elements from this map, leaving it empty.
    boolean
    Returns whether this map contains the specified key.
    boolean
    Returns whether this map contains the specified value.
    @Nullable V
    get(K key)
    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
    Returns whether this Map has no elements.
    put(V value)
    Maps the specified key to the specified value.
    @Nullable V
    remove(K key)
    Removes the mapping with the specified key from this map.
    int
    Returns the number of mappings in this Map.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 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.
      See Also:
    • containsKey

      public boolean containsKey(K key)
      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

      public boolean containsValue(V value)
      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

      public @Nullable V get(K key)
      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

      public V put(V value)
      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

      public @Nullable V remove(K key)
      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

      public @Nullable V getNextValue()
      Special API to return next value - substitute of regular Map.values.iterator().next().
      Returns:
      next available value or null if none available