question: private void ensureCapacity ( int numMappings ) { int newCapacity = Collections . roundUpToPowerOfTwo ( capacityForInitSize ( numMappings ) ) ; HashMapEntry < K , V > [ ] oldTable = table ; int oldCapacity = oldTable . length ; if ( newCapacity <= oldCapacity ) { return ; } if ( newCapacity == oldCapacity * 2 ) { doubleCapacity ( ) ; return ; } HashMapEntry < K , V > [ ] newTable = makeTable ( newCapacity ) ; if ( size != 0 ) { int newMask = newCapacity - 1 ; for ( int i = 0 ; i < oldCapacity ; i ++ ) { for ( HashMapEntry < K , V > e = oldTable [ i ] ; e != null ; ) { HashMapEntry < K , V > oldNext = e . next ; int newIndex = e . hash & newMask ; HashMapEntry < K , V > newNext = newTable [ newIndex ] ; newTable [ newIndex ] = e ; e . next = newNext ; e = oldNext ; } } } }
target:  Ensures that the hash table has sufficient capacity to store the specified number of mappings, with room to grow. If not, it increases the capacity as appropriate. Like doubleCapacity, this method moves existing entries to new buckets as appropriate. Unlike doubleCapacity, this method can grow the table by factors of 2^n for n > 1. Hopefully, a single call to this method will be faster than multiple calls to doubleCapacity. <p>This method is called only by putAll.