On Friday, 14 February 2020 at 23:19:31 UTC, Paul Backus wrote:
On Friday, 14 February 2020 at 22:57:31 UTC, Ferhat Kurtulmuş
wrote:
findSlotInsert are called two times. Why not:
if (++aa.used * GROW_DEN > aa.dim * GROW_NUM)
aa.grow(ti.key);
auto p = aa.findSlotInsert(hash); // only one call is
enough?
if (p.deleted)
--aa.deleted;
...
If I am not wrong this modification will not corrupt the
current state of the hash table?
`used` counts both filled and deleted buckets, so it shouldn't
be incremented when changing a deleted bucket into a filled
bucket.
İf ((aa.used + 1)* GROW_DEN > aa.dim * GROW_NUM)
aa.grow(ti.key);
auto p = aa.findSlotInsert(hash); // only one call is enough?
if (p.deleted)
--aa.deleted;
else
++aa.used;