protected int index()

in core/src/main/java/gnu/trove/TIntHash.java [183:207]


  protected int index(int val) {
    byte[] states = _states;
    if (states == null) return -1;
    int[] set = _set;
    int length = states.length;
    int hash = _hashingStrategy.computeHashCode(val) & 0x7fffffff;
    int index = hash % length;

    if (states[index] != FREE &&
        (states[index] == REMOVED || set[index] != val)) {
      // see Knuth, p. 529
      int probe = 1 + (hash % (length - 2));

      do {
        index -= probe;
        if (index < 0) {
          index += length;
        }
      }
      while (states[index] != FREE &&
             (states[index] == REMOVED || set[index] != val));
    }

    return states[index] == FREE ? -1 : index;
  }