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)
| 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 |