MCPcopy Index your code
hub / github.com/antlr/codebuff / capacity

Method capacity

output/java_guava/1.4.16/Maps.java:205–217  ·  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

203
204
205 static int capacity(int expectedSize) {
206 if (expectedSize < 3) {
207 checkNonnegative(expectedSize, "expectedSize");
208 return expectedSize + 1;
209 }
210 if (expectedSize < Ints.MAX_POWER_OF_TWO) {
211 // This is the calculation used in JDK8 to resize when a putAll
212 // happens; it seems to be the most conservative calculation we
213 // can make. 0.75 is the default load factor.
214 return (int) ((float) expectedSize / 0.75F + 1.0F);
215 }
216 return Integer.MAX_VALUE; // any large value
217 }
218
219 /**
220 * 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