/**
* Grow the key array. All of the values in the current array must be re-hashed and added to the new array.
*/
private void growKeyArray() {
AtomicLongArray newKeys = emptyKeyArray(pointersAndOrdinals.length() * 2);
long valuesToAdd[] = new long[size];
int counter = 0;
/// do not iterate over these values in the same order in which they appear in the hashed array.
/// if we do so, we cause large clusters of collisions to appear (because we resolve collisions with linear probing).
for(int i=0;i<pointersAndOrdinals.length();i++) {
long key = pointersAndOrdinals.get(i);
if(key != EMPTY_BUCKET_VALUE) {
valuesToAdd[counter++] = key;
}
}
Arrays.sort(valuesToAdd);
populateNewHashArray(newKeys, valuesToAdd);
/// 70% load factor
sizeBeforeGrow = (newKeys.length() * 7) / 10;
pointersAndOrdinals = newKeys;
}