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

Method capacity

corpus/java/training/guava/collect/Maps.java:195–207  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

193 * default (0.75).
194 */
195 static int capacity(int expectedSize) {
196 if (expectedSize < 3) {
197 checkNonnegative(expectedSize, "expectedSize");
198 return expectedSize + 1;
199 }
200 if (expectedSize < Ints.MAX_POWER_OF_TWO) {
201 // This is the calculation used in JDK8 to resize when a putAll
202 // happens; it seems to be the most conservative calculation we
203 // can make. 0.75 is the default load factor.
204 return (int) ((float) expectedSize / 0.75F + 1.0F);
205 }
206 return Integer.MAX_VALUE; // any large value
207 }
208
209 /**
210 * Creates a <i>mutable</i> {@code HashMap} instance with the same mappings as

Callers 8

createMethod · 0.95
growMethod · 0.45
availableCapacityMethod · 0.45
startDrainingMethod · 0.45

Calls 1

checkNonnegativeMethod · 0.45

Tested by

no test coverage detected