Class ObjHashSet<T>

java.lang.Object
org.apache.uima.internal.util.Common_hash_support
org.apache.uima.internal.util.ObjHashSet<T>
All Implemented Interfaces:
Iterable<T>, Collection<T>, Set<T>

public class ObjHashSet<T> extends Common_hash_support implements Set<T>
A set of Objects of type T This impl is for use in a single thread case only, when table is being updated. 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

    • ObjHashSet

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

      public ObjHashSet(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
    • ObjHashSet

      public ObjHashSet(ObjHashSet<T> ohs)
      Copy constructor
      Parameters:
      ohs - -
    • ObjHashSet

      public ObjHashSet(ObjHashSet<T> ohs, boolean readOnly)
  • Method Details

    • contains

      public boolean contains(Object obj)
      Specified by:
      contains in interface Collection<T>
      Specified by:
      contains in interface Set<T>
    • 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
    • add

      public boolean add(T obj)
      Specified by:
      add in interface Collection<T>
      Specified by:
      add in interface Set<T>
      Parameters:
      obj - - the object to add
      Returns:
      true if this set did not already contain the specified element
    • remove

      public boolean 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
      Specified by:
      remove in interface Collection<T>
      Specified by:
      remove in interface Set<T>
      Parameters:
      rawKey - the value to remove
      Returns:
      true if the key was present
    • get

      public T get(int index)
      For iterator use
      Parameters:
      index - - a magic number returned by the internal find
      Returns:
      the T at that spot, or null if nothing there
    • iterator

      public Iterator<T> iterator()
      Specified by:
      iterator in interface Collection<T>
      Specified by:
      iterator in interface Iterable<T>
      Specified by:
      iterator in interface Set<T>
    • moveTo

      public int moveTo(FeatureStructure fs)
      if the fs is in the set, the iterator should return it. if not, return -1 (makes iterator invalid)
      Parameters:
      fs - position to this fs
      Returns:
      the index if present, otherwise -1;
    • toArray

      public <T2> T2[] toArray(T2[] a)
      Specified by:
      toArray in interface Collection<T>
      Specified by:
      toArray in interface Set<T>
    • toArray

      public T[] toArray()
      Specified by:
      toArray in interface Collection<T>
      Specified by:
      toArray in interface Set<T>
    • toString

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

      public boolean isEmpty()
      Specified by:
      isEmpty in interface Collection<T>
      Specified by:
      isEmpty in interface Set<T>
    • containsAll

      public boolean containsAll(Collection<?> c)
      Specified by:
      containsAll in interface Collection<T>
      Specified by:
      containsAll in interface Set<T>
    • addAll

      public boolean addAll(Collection<? extends T> c)
      Specified by:
      addAll in interface Collection<T>
      Specified by:
      addAll in interface Set<T>
    • removeAll

      public boolean removeAll(Collection<?> c)
      Specified by:
      removeAll in interface Collection<T>
      Specified by:
      removeAll in interface Set<T>
    • retainAll

      public boolean retainAll(Collection<?> c)
      Specified by:
      retainAll in interface Collection<T>
      Specified by:
      retainAll in interface Set<T>
    • 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 new_capacity, int old_capacity, Common_hash_support.CommonCopyOld2New commonCopy)
      Specified by:
      copy_to_new_table in class Common_hash_support