(int expectedEntries, double loadFactor)
| 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; |
no test coverage detected