0PricingLogin
Zig Academy · Lesson

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

  1. A Generic Stack from Scratch
  2. A Singly Linked List
  3. Using HashMap and AutoHashMap
  4. Profiling and Safety Trade-offs
← Back to Zig Academy