Class Int2ObjHashMap<T,E extends T>

java.lang.Object
org.apache.uima.internal.util.Common_hash_support
org.apache.uima.internal.util.Int2ObjHashMap<T,E>
Type Parameters:
T - the type of the component type, must match the clazz in the constructor call
E - the type of the elements
All Implemented Interfaces:
Iterable<IntEntry<E>>

public class Int2ObjHashMap<T,E extends T> extends Common_hash_support implements Iterable<IntEntry<E>>
A map<int, T> based on JCasHashMap, but without the multi-threading support This impl is for use in a single thread case only Supports shrinking (reallocating the big table) Implements Map - like interface: keys are non-0 ints - 0 is reserved for the empty key slot - Integer.MIN_VALUE is reserved for removed slot values can be anything, but null is the value returned by get if not found so values probably should not be null remove supported by replacing the value slot with null, and replacing the key slot with a "removed" token. A cleanout of removed items occurs when necessary.
  • Field Details

    • REMOVED_KEY

      private static final int REMOVED_KEY
      See Also:
    • keys

      private int[] keys
    • values

      private T[] values
    • componentType

      private final Class<T> componentType
  • Constructor Details

    • Int2ObjHashMap

      public Int2ObjHashMap(Class<T> clazz)
    • Int2ObjHashMap

      public Int2ObjHashMap(Class<T> clazz, int initialSizeBeforeExpanding)
    • Int2ObjHashMap

      private Int2ObjHashMap(Int2ObjHashMap orig)
      for use by copy
      Parameters:
      clazz -
      initialCapacity -
  • Method Details

    • findPosition

      private int findPosition(int key)
      Searches the keys for a match
      Parameters:
      key - -
      Returns:
      the probeAddr in keys array - The value[probeAddr] is 0 value if not found
    • get

      public E get(int key)
    • remove

      public E remove(int key)
    • copy_to_new_table

      protected void copy_to_new_table(int newCapacity, int oldCapacity, Common_hash_support.CommonCopyOld2New commonCopy)
      Specified by:
      copy_to_new_table in class Common_hash_support
    • containsKey

      public boolean containsKey(int key)
    • put

      public T put(int key, T value)
    • computeIfAbsent

      public T computeIfAbsent(int key, IntFunction<T> mappingFunction)
    • putIfAbsent

      public T putIfAbsent(int key, T value)
    • putInner

      public void putInner(int key, T value)
    • getSortedKeys

      public int[] getSortedKeys()
    • keyIterator

      public IntListIterator keyIterator()
    • keyIterator

      public IntListIterator keyIterator(int aKey)
    • keyValueIterator

      public IntKeyValueIterator keyValueIterator(int aKey)
    • values

      public Iterator<E> values()
      Returns:
      an iterator<T> over the values in random order
    • valuesArray

      public T[] valuesArray()
    • copy

      public Int2ObjHashMap<T,E> copy()
    • iterator

      public Iterator<IntEntry<E>> iterator()
      Specified by:
      iterator in interface Iterable<T>
    • keys_length

      protected int keys_length()
      Specified by:
      keys_length in class Common_hash_support
    • is_valid_key

      protected boolean is_valid_key(int pos)
      Specified by:
      is_valid_key in class Common_hash_support
    • newKeysAndValues

      protected void newKeysAndValues(int size)
      Specified by:
      newKeysAndValues in class Common_hash_support
    • clearKeysAndValues

      protected void clearKeysAndValues()
      Specified by:
      clearKeysAndValues in class Common_hash_support