in csrc/suffix_decoding/int32_map.h [316:345]
bool probe_insert_or_find_(int32_t key, uint32_t& idx_out) const {
assert(slots_ && cap_ > 0 && "probe on uninitialized map");
uint32_t idx = mix_hash_(key) & (cap_ - 1);
uint32_t step = 0;
bool has_first_tomb = false;
uint32_t first_tomb_idx = 0;
for (uint32_t probes = 0; probes < cap_; ++probes) {
int32_t k = slots_[idx].key;
if (k == key) {
idx_out = idx;
return true;
}
if (k == KEY_EMPTY) {
idx_out = has_first_tomb ? first_tomb_idx : idx;
return false;
}
if (k == KEY_TOMBSTONE && !has_first_tomb) {
first_tomb_idx = idx;
has_first_tomb = true;
}
++step;
idx = (idx + step) & (cap_ - 1); // triangular probing
}
if (!has_first_tomb) {
// This should never happen if load factor is correctly maintained.
throw std::runtime_error("Int32Map is full");
}
idx_out = first_tomb_idx;
return false;
}