(int x)
| 282 | /// |
| 283 | /// storage size |
| 284 | private static final int calculateCapacity(int x) { |
| 285 | if(x >= 1 << 30){ |
| 286 | return 1 << 30; |
| 287 | } |
| 288 | if(x == 0){ |
| 289 | return 16; |
| 290 | } |
| 291 | x = x -1; |
| 292 | x |= x >> 1; |
| 293 | x |= x >> 2; |
| 294 | x |= x >> 4; |
| 295 | x |= x >> 8; |
| 296 | x |= x >> 16; |
| 297 | return x + 1; |
| 298 | } |
| 299 | |
| 300 | /// Constructs a new `HashMap` instance with the specified capacity and |
| 301 | /// load factor. |