MCPcopy Create free account
hub / github.com/antlr/codebuff / closedTableSize

Method closedTableSize

corpus/java/training/guava/collect/Hashing.java:56–67  ·  view source on GitHub ↗
(int expectedEntries, double loadFactor)

Source from the content-addressed store, hash-verified

54 private static final int MAX_TABLE_SIZE = Ints.MAX_POWER_OF_TWO;
55
56 static int closedTableSize(int expectedEntries, double loadFactor) {
57 // Get the recommended table size.
58 // Round down to the nearest power of 2.
59 expectedEntries = Math.max(expectedEntries, 2);
60 int tableSize = Integer.highestOneBit(expectedEntries);
61 // Check to make sure that we will not exceed the maximum load factor.
62 if (expectedEntries > (int) (loadFactor * tableSize)) {
63 tableSize <<= 1;
64 return (tableSize > 0) ? tableSize : MAX_TABLE_SIZE;
65 }
66 return tableSize;
67 }
68
69 static boolean needsResizing(int size, int tableSize, double loadFactor) {
70 return size > loadFactor * tableSize && tableSize < MAX_TABLE_SIZE;

Callers 15

fromEntryArrayMethod · 0.95
initMethod · 0.95
fromEntryArrayMethod · 0.95
ValueSetMethod · 0.95
fromEntryArrayMethod · 0.95
initMethod · 0.95
fromEntryArrayMethod · 0.95
ValueSetMethod · 0.95
fromEntryArrayMethod · 0.95

Calls 1

maxMethod · 0.45

Tested by

no test coverage detected