protected void rehash ( int newCapacity ) { HashIntSet rehashed = new HashIntSet ( newCapacity ) ; @ SuppressWarnings ( "hiding" ) int [ ] cells = rehashed . cells ; for ( int element : this . cells ) { if ( element < 0 ) // removed or empty { continue ; } // add the element cells [ - ( rehashed . findElementOrEmpty ( element ) + 1 ) ] = element ; } this . cells = cells ; freecells = newCapacity - size ; modCount ++ ; }
Rehashes to a bigger size .