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)
| 203 | |
| 204 | |
| 205 | static int capacity(int expectedSize) { |
| 206 | if (expectedSize < 3) { |
| 207 | checkNonnegative(expectedSize, "expectedSize"); |
| 208 | return expectedSize + 1; |
| 209 | } |
| 210 | if (expectedSize < Ints.MAX_POWER_OF_TWO) { |
| 211 | // This is the calculation used in JDK8 to resize when a putAll |
| 212 | // happens; it seems to be the most conservative calculation we |
| 213 | // can make. 0.75 is the default load factor. |
| 214 | return (int) ((float) expectedSize / 0.75F + 1.0F); |
| 215 | } |
| 216 | return Integer.MAX_VALUE; // any large value |
| 217 | } |
| 218 | |
| 219 | /** |
| 220 | * Creates a <i>mutable</i> {@code HashMap} instance with the same mappings as |
no test coverage detected