Creates a {@code HashMap} instance, with a high enough "initial capacity" that it <i>should</i> hold {@code expectedSize} elements without growth. This behavior cannot be broadly guaranteed, but it is observed to be true for OpenJDK 1.7. It also can't be guaranteed that the method isn't inadvertentl
(int expectedSize)
| 250 | * @throws IllegalArgumentException if {@code expectedSize} is negative |
| 251 | */ |
| 252 | @SuppressWarnings("NonApiType") // acts as a direct substitute for a constructor call |
| 253 | public static <K extends @Nullable Object, V extends @Nullable Object> |
| 254 | HashMap<K, V> newHashMapWithExpectedSize(int expectedSize) { |
| 255 | return new HashMap<>(capacity(expectedSize)); |
| 256 | } |
| 257 | |
| 258 | /** |
| 259 | * Returns a capacity that is sufficient to keep the map from being resized as long as it grows no |