private void enlarge ( ) { int oldCapacity = keys . length ; if ( oldCapacity == LinearProbing . MAXIMUM_CAPACITY ) throw new IllegalArgumentException ( "Map cannot grow beyond capacity: " + LinearProbing . MAXIMUM_CAPACITY ) ; K oldKeys [ ] = keys ; V oldValues [ ] = values ; int newCapacity = oldCapacity << 1 ; @ SuppressWarnings ( "unchecked" ) K newKeys [ ] = ( K [ ] ) new Object [ newCapacity ] ; @ SuppressWarnings ( "unchecked" ) V newValues [ ] = ( V [ ] ) new Object [ newCapacity ] ; for ( int i = 0 ; i < oldCapacity ; i ++ ) { K key = oldKeys [ i ] ; if ( key != null ) putKeyValue ( newKeys , newValues , key , oldValues [ i ] ) ; } this . keys = newKeys ; this . values = newValues ; }
Increasing the capacity of the map