Skip to main content

Module hash_map

Module hash_map 

Source
Expand description

Swiss-table inspired open-addressing hash map.

ExHashMap is a high-performance hash map that uses a separate control byte array to enable parallel SIMD key probing — the same technique used by Google’s Abseil flat_hash_map and Rust’s hashbrown.

§Algorithm Overview

Each slot has a one-byte control byte stored in a contiguous ctrl array. The control byte is either:

  • [CTRL_EMPTY] (0x80) — the slot is vacant.
  • A 7-bit hash tag h2(hash) — the slot is occupied by a key whose upper-57-bit hash matches h2.

Lookups load a 16-byte [Group] from ctrl and use SIMD to find all slots whose tag matches the query in a single instruction, drastically reducing branch mispredictions and cache misses compared to traditional chaining or linear probing.

§Load Factor

The table grows when len * 8 >= cap * 7 (87.5 % load factor).

§Context Trait

Hashing and equality are provided by the HashContext<K> trait rather than being hard-coded via Hash / Eq. This allows callers to choose domain-specific hash functions without wrapper types.

Structs§

ExHashMap
A high-performance open-addressing hash map with SIMD probing.