4 ms·
Hash tables do that automatically. Rehashing is controlled by various tunable strategies: Load factor (0.5-1), growth policy (primed or power2), growth factor
by rurban 6y ago
Hash tables do that automatically.
Rehashing is controlled by various tunable strategies: Load factor (0.5-1), growth policy (primed or power2), growth factor (1.5, golden ratio or 2).
Linked list tables don't need to throw away nodes, they can just be relinked. But compaction is always better, because cache dominates. Most rehash do exactly that. Esp. multithreaded.
The best thing to do is to take a good one and don't touch it, unless you want a monster as in perl5. Eg the recent siphash security theater broke performance in all dynamic languages, even the linux kernel. Everything is perl now. You don't want that.