public int index(long key) {
    if (key == 0) {
      return containsNullKey ? tableSize : -(tableSize + 1);
    }

    long current;
    long[] keys = this.keys;
    int index;
    // the starting point
    if ((current = keys[index = (int)key & mask]) == 0) {
      return -(index + 1);
    }
    if (key == current) {
      return index;
    }
    // there's always an unused entry
    while (true) {
      if ((current = keys[index = index + 1 & mask]) == 0) {
        return -(index + 1);
      }
      if (key == current) {
        return index;
      }
    }
  }
public int index(long key)