protected void rehash ( int newCapacity ) { int oldCapacity = table . length ; //if (oldCapacity == newCapacity) return; long oldTable [ ] = table ; int oldValues [ ] = values ; byte oldState [ ] = state ; long newTable [ ] = new long [ newCapacity ] ; int newValues [ ] = new int [ newCapacity ] ; byte newState [ ] = new byte [ newCapacity ] ; this . lowWaterMark = chooseLowWaterMark ( newCapacity , this . minLoadFactor ) ; this . highWaterMark = chooseHighWaterMark ( newCapacity , this . maxLoadFactor ) ; this . table = newTable ; this . values = newValues ; this . state = newState ; this . freeEntries = newCapacity - this . distinct ; // delta for ( int i = oldCapacity ; i -- > 0 ; ) { if ( oldState [ i ] == FULL ) { long element = oldTable [ i ] ; int index = indexOfInsertion ( element ) ; newTable [ index ] = element ; newValues [ index ] = oldValues [ i ] ; newState [ index ] = FULL ; } } }
Rehashes the contents of the receiver into a new table with a smaller or larger capacity . This method is called automatically when the number of keys in the receiver exceeds the high water mark or falls below the low water mark .