Hashmap v2.0
Hashmap 2.0 Highlights:
- New generic and type-safe API. We no longer need to use a macro to generate type-safe wrapper functions.
- Improved linear probing algorithm. The previous algorithm could fail on insert, rehash, or remove if a particularly poor hash function was provided. The new algorithm can never fail, even with a worst-case hash function. This adds user confidence and reduces failure modes.
- Added a supplemental hash function. Linear probing is especially sensitive to clustering due to poor hash functions. Since the hash function is user-supplied, adding a supplemental hash function provides more consistent performance.
- Now, always provide hashmap statistics API with no additional overhead to ordinary hashmap operations.
- Now, do lazy allocation on init. We reserve no memory on the heap until the first item is added.
- Default hashmap size is reduced to 128 elements.
- A hashmap_reserve() function was added to pre-allocate the hashmap.
- hashmap_foreach macros have been added to hide the complexities of iterator usage and streamline iteration.