MCPcopy
hub / github.com/google/guava / newHashMapWithExpectedSize

Method newHashMapWithExpectedSize

guava/src/com/google/common/collect/Maps.java:252–256  ·  view source on GitHub ↗

Creates a {@code HashMap} instance, with a high enough "initial capacity" that it <i>should</i> hold {@code expectedSize} elements without growth. This behavior cannot be broadly guaranteed, but it is observed to be true for OpenJDK 1.7. It also can't be guaranteed that the method isn't inadvertentl

(int expectedSize)

Source from the content-addressed store, hash-verified

250 * @throws IllegalArgumentException if {@code expectedSize} is negative
251 */
252 @SuppressWarnings("NonApiType") // acts as a direct substitute for a constructor call
253 public static <K extends @Nullable Object, V extends @Nullable Object>
254 HashMap<K, V> newHashMapWithExpectedSize(int expectedSize) {
255 return new HashMap<>(capacity(expectedSize));
256 }
257
258 /**
259 * Returns a capacity that is sufficient to keep the map from being resized as long as it grows no

Callers 9

createMethod · 0.95
createMethod · 0.95
HashMultisetMethod · 0.95
createMethod · 0.95
hasCycleMethod · 0.95
createMapMethod · 0.95

Calls 1

capacityMethod · 0.95