Open zacknewman opened 2 days ago
I can sporadically trigger a reallocation in as few as 25 inserts (i.e., after ≈ 13% of the originally reported capacity—which is 192 on my machine—is added).
Is it possible to calculate a lower bound like HashMap::capacity
?
Returns the number of elements the map can hold without reallocating.
This number is a lower bound; the
HashMap<K, V>
might be able to hold more, but is guaranteed to be able to hold at least this many.
Either there is a bug in code, or the documentation needs to be changed for
capacity
. The documentation states (emphasis added):The following code illustrates a reallocation occurs before inserting more than
capacity
key-value pairs.Unsurprisingly, the same problem exists for
DashSet
.