Class Int2IntHashMap

java.lang.Object
org.apache.uima.internal.util.Int2IntHashMap

public class Int2IntHashMap extends Object
A map<int, int> 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 and values are ints Entry set not (yet) impl keys must be non-0; 0 is reserved to be an empty slot values can be anything, but 0 is the value returned by get if not found so values probably should not be 0
  • Field Details

    • TUNE

      private static final boolean TUNE
      See Also:
    • EMPTY_INT_ARRAY

      private static final int[] EMPTY_INT_ARRAY
    • loadFactor

      private final float loadFactor
      See Also:
    • initialCapacity

      private final int initialCapacity
    • histogram

      private int[] histogram
    • maxProbe

      private int maxProbe
    • sizeWhichTriggersExpansion

      private int sizeWhichTriggersExpansion
    • size

      private int size
    • keys

      private int[] keys
    • values

      private int[] values
    • secondTimeShrinkable

      private boolean secondTimeShrinkable
  • Constructor Details

    • Int2IntHashMap

      public Int2IntHashMap()
    • Int2IntHashMap

      public Int2IntHashMap(int initialCapacity)
  • Method Details

    • nextHigherPowerOf2

      static int nextHigherPowerOf2(int i)
    • newTableKeepSize

      private void newTableKeepSize(int capacity)
    • incrementSize

      private void incrementSize()
    • increaseTableCapacity

      private void increaseTableCapacity()
    • newTable

      private void newTable(int capacity)
    • resetHistogram

      private void resetHistogram()
    • clear

      public void clear()
    • find

      private int find(int key)
      It gets a ref to the current value of table, and then searches that int array.
      Parameters:
      key - -
      Returns:
      the probeAddr in keys array - might have a 0 value, or the key value if found
    • find2

      private int find2(int[] localKeys, int key, int probeAddr)
    • updateHistogram

      private void updateHistogram(int nbrProbes)
    • get

      public int get(int key)
    • containsKey

      public boolean containsKey(int key)
    • isKeyValid

      public boolean isKeyValid(int position)
    • put

      public int put(int key, int value)
    • putInner

      public void putInner(int key, int value)
    • size

      public int size()
    • moveToNextFilled

      private int moveToNextFilled(int pos)
      advance pos until it points to a non 0 or is 1 past end
      Parameters:
      pos -
      Returns:
      updated pos
    • moveToPreviousFilled

      private int moveToPreviousFilled(int pos)
      decrement pos until it points to a non 0 or is -1
      Parameters:
      pos -
      Returns:
      updated pos
    • getSortedKeys

      public int[] getSortedKeys()
    • keyIterator

      public IntListIterator keyIterator()
    • keyIterator

      public IntListIterator keyIterator(int aKey)
    • keyValueIterator

      public IntKeyValueIterator keyValueIterator()
    • keyValueIterator

      public IntKeyValueIterator keyValueIterator(int aKey)
    • showHistogram

      public void showHistogram()