Sample Video Frame
Exercise 38: Hashmap Algorithms
There are three hash functions that you'll implement in this exercise:
- FNV-1a: Named after the creators Glenn Fowler, Phong Vo, and Landon Curt Noll, this hash produces good numbers and is reasonably fast.
- Adler-32: Named after Mark Adler, this is a horrible hash algorithm, but it's been around a long time and it's good for studying.
- DJB Hash: This hash algorithm is attributed to Dan J. Bernstein (DJB), but it's difficult to find his discussion of the algorithm. It's shown to be fast, but possibly not great numbers.
You've already seen the Jenkins hash as the default hash for the Hashmap data structure, so this exercise will be looking at these three new hash functions. The code for them is usually small, and it's not optimized at all. As usual, I'm going for understanding and not blinding speed.
The header file is very simple, so I'll start with that:
Register for Learn C the Hard Way
Register today for the course and get the all currently available videos and lessons, plus all future modules for no extra charge.