Class Obj2IntIdentityHashMap<T>

java.lang.Object
org.apache.uima.internal.util.Common_hash_support
org.apache.uima.internal.util.Obj2IntIdentityHashMap<T>

public class Obj2IntIdentityHashMap<T> extends Common_hash_support
A Map from non-null Objects of type T to ints int value 0 reserved to mean object is not in the table. This impl is for use in a single thread case only, for table updates Multiple reader threads are OK if there's no writing. Supports shrinking (reallocating the big table) Removed objects replaced with special marker object in the table so find operations continue to work (they can't stop upon finding this object).
  • Constructor Details

    • Obj2IntIdentityHashMap

      public Obj2IntIdentityHashMap(Class<T> clazz, T removedMarker)
    • Obj2IntIdentityHashMap

      public Obj2IntIdentityHashMap(int initialCapacity, Class<T> clazz, T removedMarker)
      Parameters:
      initialCapacity - - you can add this many before expansion
      clazz - - a superclass of the stored items
      removedMarker - - a unique value never stored in the table, used to mark removed items
  • Method Details

    • contains

      public boolean contains(Object obj)
    • find

      public int find(T obj)
      Parameters:
      obj - the object to find in the table (if it is there)
      Returns:
      the position of obj in the table, or -1 if not in the table
    • get

      public int get(T obj)
    • put

      public int put(T obj, int value)
      Parameters:
      obj - the key
      value - the value
      Returns:
      the previous value, or 0 if this map did not already contain the specified key
    • remove

      public int remove(Object rawKey)
      Can't replace the item with a null because other keys that were stored in the table which previously collided with the removed item won't be found. UIMA-4204
      Parameters:
      rawKey - the value to remove
      Returns:
      the value previously associated with the key, or 0 if none
    • getKeys

      public T[] getKeys()
    • iterator

      public IntListIterator iterator()
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • is_valid_key

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

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

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

      protected void clearKeysAndValues()
      Specified by:
      clearKeysAndValues in class Common_hash_support
    • 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