mirror of
https://github.com/maxkratz/fastutil.git
synced 2024-09-16 11:58:09 +00:00
Hash-based containers now expose ensureCapacity()
This commit is contained in:
parent
ac10cae36e
commit
85bb33b1bf
3 changed files with 16 additions and 2 deletions
4
CHANGES
4
CHANGES
|
@ -1,3 +1,7 @@
|
|||
8.5.11
|
||||
|
||||
- Hash-based containers now expose ensureCapacity().
|
||||
|
||||
8.5.10
|
||||
|
||||
- Really fixed overflow bug in BigArrays.ensureOffsetLength(). Thanks
|
||||
|
|
|
@ -504,7 +504,12 @@ public class OPEN_HASH_MAP KEY_VALUE_GENERIC extends ABSTRACT_MAP KEY_VALUE_GENE
|
|||
return containsNullKey ? size - 1 : size;
|
||||
}
|
||||
|
||||
private void ensureCapacity(final int capacity) {
|
||||
/** Ensures that this map can hold a certain number of keys without rehashing.
|
||||
*
|
||||
* @param capacity a number of keys; there will be no rehashing unless
|
||||
* the map {@linkplain #size() size} exceeds this number.
|
||||
*/
|
||||
public void ensureCapacity(final int capacity) {
|
||||
final int needed = arraySize(capacity, f);
|
||||
if (needed > n) rehash(needed);
|
||||
}
|
||||
|
|
|
@ -756,7 +756,12 @@ public class OPEN_HASH_SET KEY_GENERIC extends ABSTRACT_SET KEY_GENERIC implemen
|
|||
return containsNull ? size - 1 : size;
|
||||
}
|
||||
|
||||
private void ensureCapacity(final int capacity) {
|
||||
/** Ensures that this 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 #size() size} exceeds this number.
|
||||
*/
|
||||
public void ensureCapacity(final int capacity) {
|
||||
final int needed = arraySize(capacity, f);
|
||||
if (needed > n) rehash(needed);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue