threshold = (int) (newTable.length * loadFactor);
int sizeMask = newTable.length - 1;
for ( int i = 0; i < oldCapacity; i++ ) {
// We need to guarantee that any existing reads of old Map can
// proceed. So we cannot yet null out each bin.
RightTupleList e = oldTable[i];
if ( e != null ) {
RightTupleList next = (RightTupleList) e.getNext();
int idx = e.hashCode() & sizeMask;
// Single node on list
if ( next == null ) newTable[idx] = e;
else {
// Reuse trailing consecutive sequence at same slot
RightTupleList lastRun = e;
int lastIdx = idx;
for ( RightTupleList last = next; last != null; last = (RightTupleList) last.getNext() ) {
int k = last.hashCode() & sizeMask;
if ( k != lastIdx ) {
lastIdx = k;
lastRun = last;
}
}
newTable[lastIdx] = lastRun;
// Clone all remaining nodes
for ( RightTupleList p = e; p != lastRun; p = (RightTupleList) p.getNext() ) {
int k = p.hashCode() & sizeMask;
RightTupleList n = newTable[k];
newTable[k] = new RightTupleList( p, n );
}
}
}
}
table = newTable;