private void rehash() {
    int[] newKeys = new int[keys.length << 1];
    T[] newValues = arrayFactory.produce(newKeys.length);

    for (int i = keys.length - 1; i >= 0; i--) {
      int key = keys[i];
      if (key != 0) {
        int index = hashIndex(newKeys, key);
        newValues[index] = values[i];
        if (newKeys[index] == 0) {
          newKeys[index] = key;
        }
      }
    }

    keys = newKeys;
    values = newValues;
  }
private void rehash()