Import with #import "std/hash_map".

HashMap :: struct($K: Type, $V: Type) { keys: Vec(K); values: Vec(V); states: Vec(u8); count: s64; removed: s64; }
HashKey :: (key: string) -> u64

FNV-1a over the key's bytes.

HashKey :: (key: u64) -> u64

SplitMix64's finalizer spreads nearby integers across the table.

HashKey :: (key: s64) -> u64
HashKey :: (key: u32) -> u64

Unsigned keys up to 32 bits; also the closest match for u8 and u16.

HashMapFind :: (map: *HashMap($K, $V), key: K) -> s64

The slot holding KEY, or -1.

HashMapHas :: (map: *HashMap($K, $V), key: K) -> bool
HashMapGet :: (map: *HashMap($K, $V), key: K, value: *V) -> bool

Copies KEY's value into VALUE and returns true, or returns false.

HashMapSet :: (map: *HashMap($K, $V), key: K, value: V)
HashMapRemove :: (map: *HashMap($K, $V), key: K) -> bool

Removes KEY and returns whether it was present.

HashMapFree :: (map: *HashMap($K, $V))
HashMapGrow :: (map: *HashMap($K, $V))

Doubles the table, to at least 8 slots, and reinserts every entry.

HashMapRehash :: (map: *HashMap($K, $V), capacity: s64)

Rebuild live entries, discarding deleted slots without growing the table.

Source ↗ · All modules