Naive HashMap

How else could we implement an associative array in Rust and how would it compare to standard library's HashMap? The standard library HashMap is clever, clearly, storing just enough information to reduce the total probes from ideal offsets by sharing information between modifications to the underlying table. In fact, the comments in the table module assert that the design we've just worked through is a lot faster than a table structured as Vec<Option<(u64, K, V)>>—where u64 is the key hash, but presumably still using Robin Hood hashing and linear probing. What if we went even simpler? We'll support only two operations—insert and lookup—to keep things straightforward for ourselves. We'll also keep more or less the same type constraints ...

Get Hands-On Concurrency with Rust now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.