-
Notifications
You must be signed in to change notification settings - Fork 0
Hash table
Hash tables are data structures that store values with keys using hash codes of the keys. Hash codes are then used as index into an array of entires (key/value pairs).
A classic way to store entries with the same has code is a linked list. This is not great for modern CPUs as it involves chasing points.
Another way to handle storing entries with the same has code is linear probing the array of entries, i.e. check entry N+1 in a loop. This is proven to be faster than chained hash tables on modern CPUs.
Robin Hood hashing which is a varient of open-address hashing that gives preference to entries closer to there ideal position in the hash table, minimizing the number of probes that are needed to find the correct entry. There are some interesting articals on Robin Hood Hashing and how to handle deletion. There is an MIT licensed C# implementation available, based on the implementation in Rust.
Robin Hood Hashing also tolerates higher load factors, meaning hash tables tend to be faster, have more constant performance (less variation), use less memory and create less garbage.
© Chris Austin 2018-2024