private static int computeCapacity ( final int expectedSize ) { if ( expectedSize == 0 ) { return 1 ; } final int capacity = ( int ) InternalFastMath . ceil ( expectedSize / LOAD_FACTOR ) ; final int powerOfTwo = Integer . highestOneBit ( capacity ) ; if ( powerOfTwo == capacity ) { return capacity ; } return nextPowerOfTwo ( capacity ) ; }
Compute the capacity needed for a given size .