Returns a capacity that is sufficient to keep the map from being resized as long as it grows no larger than expectedSize and the load factor is >= its default (0.75).
(int expectedSize)
| 193 | * default (0.75). |
| 194 | */ |
| 195 | static int capacity(int expectedSize) { |
| 196 | if (expectedSize < 3) { |
| 197 | checkNonnegative(expectedSize, "expectedSize"); |
| 198 | return expectedSize + 1; |
| 199 | } |
| 200 | if (expectedSize < Ints.MAX_POWER_OF_TWO) { |
| 201 | // This is the calculation used in JDK8 to resize when a putAll |
| 202 | // happens; it seems to be the most conservative calculation we |
| 203 | // can make. 0.75 is the default load factor. |
| 204 | return (int) ((float) expectedSize / 0.75F + 1.0F); |
| 205 | } |
| 206 | return Integer.MAX_VALUE; // any large value |
| 207 | } |
| 208 | |
| 209 | /** |
| 210 | * Creates a <i>mutable</i> {@code HashMap} instance with the same mappings as |
no test coverage detected