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

Method newHashSetWithExpectedSize

guava/src/com/google/common/collect/Sets.java:263–267  ·  view source on GitHub ↗

Returns a new hash set using the smallest initial table size that can hold {@code expectedSize} elements without resizing. Note that this is not what {@link HashSet#HashSet(int)} does, but it is what most users want and expect it to do. <p>This behavior can't be broadly guaranteed, but has been tes

(
      int expectedSize)

Source from the content-addressed store, hash-verified

261 * @throws IllegalArgumentException if {@code expectedSize} is negative
262 */
263 @SuppressWarnings("NonApiType") // acts as a direct substitute for a constructor call
264 public static <E extends @Nullable Object> HashSet<E> newHashSetWithExpectedSize(
265 int expectedSize) {
266 return new HashSet<>(Maps.capacity(expectedSize));
267 }
268
269 /**
270 * Creates a thread-safe set backed by a hash map. The set is backed by a {@link

Callers 14

retainAllMethod · 0.95
DistinctKeyIteratorClass · 0.95
newHashSetMethod · 0.95
UndirectedMethod · 0.95
createDataMethod · 0.95
checkExactMatchesMethod · 0.95
assertInvariantsMethod · 0.95

Calls 1

capacityMethod · 0.95