Using HashMap and AutoHashMap
Key-value storage from std.
Why a Hash Map
A hash map stores key-value pairs and looks them up in near-constant time. Zig ships one in the standard library, so you rarely write your own. 🗺️
Reach for AutoHashMap First
std.AutoHashMap picks hashing and equality automatically for common key types like integers and enums. Give it a key type and a value type.
const Map = std.AutoHashMap(u32, []const u8);All lessons in this course
- A Generic Stack from Scratch
- A Singly Linked List
- Using HashMap and AutoHashMap
- Profiling and Safety Trade-offs