Skip to main content

Module det_map

Module det_map 

Source
Expand description

Deterministic hash map using MurmurHash3 – iteration order is fixed. Deterministic map with insertion-order iteration.

Provides DetMap, an open-addressing hash map that uses MurmurHash3 with a fixed seed and Fibonacci hashing for slot selection. Iteration order follows insertion order, not hash order, making output deterministic across runs and platforms.

§Determinism guarantees

  • MurmurHash3 with a compile-time fixed seed produces identical hashes on every run.
  • Fibonacci hashing maps hash values to slots without random state.
  • Insertion-order iteration is maintained via an auxiliary order vector.
  • Growth (rehash) preserves insertion order.

§When to use

Use DetMap instead of HashMap when the CJC runtime needs a key-value store whose iteration order must be reproducible (e.g., for struct field serialization, JSON emission, or deterministic fold operations). For cases where only sorted-key order is needed, prefer BTreeMap.

Structs§

DetMap
A deterministic hash map with insertion-order iteration. Uses open addressing with Fibonacci hashing.

Functions§

murmurhash3
Hash a byte slice using MurmurHash3 with a fixed compile-time seed.
murmurhash3_finalize
Apply the MurmurHash3 64-bit finalizer to a hash value.
value_hash
Compute a deterministic hash for a CJC Value.
values_equal_static
Test two Values for structural equality without interpreter context.