Hash-based big sets now expose ensureCapacity()

This commit is contained in:
Sebastiano Vigna 2022-10-12 14:47:25 +02:00
parent 85bb33b1bf
commit 540fed8147

View file

@ -341,7 +341,12 @@ public class OPEN_HASH_BIG_SET KEY_GENERIC extends ABSTRACT_SET KEY_GENERIC impl
return containsNull ? size - 1 : size;
}
private void ensureCapacity(final long capacity) {
/** Ensures that this big set can hold a certain number of elements without rehashing.
*
* @param capacity a number of elements; there will be no rehashing unless
* the set {@linkplain #size64() size} exceeds this number.
*/
public void ensureCapacity(final long capacity) {
final long needed = bigArraySize(capacity, f);
if (needed > n) rehash(needed);
}