Class Int2ObjHashMap<T,​E extends T>

  • 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:
    java.lang.Iterable<IntEntry<E>>

    public class Int2ObjHashMap<T,​E extends T>
    extends Common_hash_support
    implements java.lang.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 Detail

      • keys

        private int[] keys
      • values

        private T[] values
      • componentType

        private final java.lang.Class<T> componentType
    • Constructor Detail

      • Int2ObjHashMap

        public Int2ObjHashMap​(java.lang.Class<T> clazz)
      • Int2ObjHashMap

        public Int2ObjHashMap​(java.lang.Class<T> clazz,
                              int initialSizeBeforeExpanding)
      • Int2ObjHashMap

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

      • 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)
      • containsKey

        public boolean containsKey​(int key)
      • put

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

        public T computeIfAbsent​(int key,
                                 java.util.function.IntFunction<T> mappingFunction)
      • putIfAbsent

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

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

        public int[] getSortedKeys()
      • values

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

        public T[] valuesArray()
      • iterator

        public java.util.Iterator<IntEntry<E>> iterator()
        Specified by:
        iterator in interface java.lang.Iterable<T>