MCPcopy Create free account
hub / github.com/codenameone/CodenameOne / calculateCapacity

Method calculateCapacity

vm/JavaAPI/src/java/util/HashMap.java:282–296  ·  view source on GitHub ↗

Calculates the capacity of storage required for storing given number of elements @param x number of elements @return storage size

(int x)

Source from the content-addressed store, hash-verified

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

Callers 2

HashMapMethod · 0.95
rehashMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected