Hash Table

A high-performance Linear Probing map optimized for Arena usage.

Concept & Motivation

The Problem: Chained Hash Maps (Linked Lists) cause memory fragmentation.

The Solution: Linear Probing. We use a single contiguous array. If a slot is taken, we step forward until we find a free one. This is extremely friendly to CPU caches.

Architecture

  • Algorithm: FNV-1a Hash.

  • Collision Resolution: Linear Probing.

  • Load Factor: Resizes at 75% capacity.

circle-exclamation

API Reference

table.put / table.get

Maps a String key to a value pointer.

Table cfg = table.create(&arena, 64);
int val = 100;

table.put(&cfg, string.from("Width"), &val);
int *got = table.get(&cfg, string.from("Width"));

Last updated