protected void rehash()

in core/src/main/java/gnu/trove/THashMap.java [330:349]


  protected void rehash(int newCapacity) {
    int oldCapacity = _set.length;
    Object[] oldKeys = _set;
    V[] oldVals = _values;

    _set = new Object[newCapacity];
    _values = (V[])new Object[newCapacity];

    for (int i = oldCapacity; i-- > 0; ) {
      if (oldKeys[i] != null && oldKeys[i] != REMOVED) {
        Object o = oldKeys[i];
        int index = insertionIndex((K)o);
        if (index < 0) {
          throwObjectContractViolation(_set[-index - 1], o);
        }
        _set[index] = o;
        _values[index] = oldVals[i];
      }
    }
  }