Skip to content

MapPolicy

Description

Probing / rehash policy currently installed on m. The returned MapPolicy value is borrowed from inside the map – read-only.

Parameters

Name Direction Description
m in Map.

Usage example (Cross-references)

Usage examples (Cross-references)
        MapPolicyNextIndexFn    next_index;
        size                    max_probe_count;
    } MapPolicy;
    
    ///
    /// TAGS: Map, Constant, Policy
    ///
    extern const MapPolicy MapPolicyLinear;
    
    ///
    /// TAGS: Map, Constant, Policy
    ///
    extern const MapPolicy MapPolicyQuadratic;
    
    typedef struct {
        u8               *entries;
        u8               *states;
        MapPolicy         policy;
        Allocator        *allocator;
        u64               __magic;
            MapEntry(K, V) * entries;                                                                                      \
            u8        *states;                                                                                             \
            MapPolicy  policy;                                                                                             \
            Allocator *allocator;                                                                                          \
            u64        __magic;                                                                                            \
    }
    
    void validate_map_policy(const MapPolicy *policy) {
        static const struct {
            u64 length;
    
        if (!policy) {
            LOG_FATAL("Expected a valid MapPolicy pointer");
        }
    
        if (!policy->name || !policy->name[0]) {
            LOG_FATAL("MapPolicy must have a non-empty name");
        }
    
        if (!policy->should_rehash || !policy->next_capacity || !policy->first_index || !policy->next_index) {
            LOG_FATAL("MapPolicy '{}' must provide all required callbacks", policy->name);
        }
    
        if (policy->max_probe_count == 0) {
            LOG_FATAL("MapPolicy '{}' must provide a non-zero max_probe_count", policy->name);
        }
    
            if ((next0 == 0) && ((length != 0) || (capacity != 0) || (tombstones != 0))) {
                LOG_FATAL("MapPolicy '{}' returned zero capacity for a non-empty snapshot", policy->name);
            }
    
            if ((next_same != 0) && (next_same < length)) {
                LOG_FATAL("MapPolicy '{}' returned capacity smaller than current length", policy->name);
            }
    
            if (next_more < ((size)length + 1)) {
                LOG_FATAL("MapPolicy '{}' returned capacity smaller than requested minimum entries", policy->name);
            }
        }
    
                if (next == first) {
                    LOG_FATAL("MapPolicy '{}' produced a stuck probe sequence for capacity {}", policy->name, capacity);
                }
            }
    }
    
    MapPolicy validate_map_policy_copy(MapPolicy policy) {
        validate_map_policy(&policy);
        return policy;
    }
    
    const MapPolicy MapPolicyLinear = {
        .name            = "linear",
        .should_rehash   = default_should_rehash,
    };
    
    const MapPolicy MapPolicyQuadratic = {
        .name            = "quadratic",
        .should_rehash   = default_should_rehash,
        size        hash_offset,
        size        n,
        MapPolicy   policy
    ) {
        u8 *old_entries;
        MapRehashWithPolicy(&map, MapPairCount(&map), MapPolicyQuadratic);
    
        bool result = (MapPolicy(&map).first_index == MapPolicyQuadratic.first_index) &&
                      (MapPolicy(&map).next_index == MapPolicyQuadratic.next_index) &&
                      (MapPolicy(&map).next_capacity == MapPolicyQuadratic.next_capacity) &&
    
        bool result = (MapPolicy(&map).first_index == MapPolicyQuadratic.first_index) &&
                      (MapPolicy(&map).next_index == MapPolicyQuadratic.next_index) &&
                      (MapPolicy(&map).next_capacity == MapPolicyQuadratic.next_capacity) &&
                      (MapPolicy(&map).should_rehash == MapPolicyQuadratic.should_rehash);
        bool result = (MapPolicy(&map).first_index == MapPolicyQuadratic.first_index) &&
                      (MapPolicy(&map).next_index == MapPolicyQuadratic.next_index) &&
                      (MapPolicy(&map).next_capacity == MapPolicyQuadratic.next_capacity) &&
                      (MapPolicy(&map).should_rehash == MapPolicyQuadratic.should_rehash);
        result = result && (MapValueCountForKey(&map, "red") == 2);
                      (MapPolicy(&map).next_index == MapPolicyQuadratic.next_index) &&
                      (MapPolicy(&map).next_capacity == MapPolicyQuadratic.next_capacity) &&
                      (MapPolicy(&map).should_rehash == MapPolicyQuadratic.should_rehash);
        result = result && (MapValueCountForKey(&map, "red") == 2);
        result = result && MapGetFirstPtr(&map, "red") && (ZstrCompare(*MapGetFirstPtr(&map, "red"), "apple") == 0);
    
        // Policy is now quadratic (copied in by value).
        result = result && (MapPolicy(&map).first_index == MapPolicyQuadratic.first_index);
        result = result && (MapPolicy(&map).next_index == MapPolicyQuadratic.next_index);
        result = result && (MapPolicy(&map).next_capacity == MapPolicyQuadratic.next_capacity);
        // Policy is now quadratic (copied in by value).
        result = result && (MapPolicy(&map).first_index == MapPolicyQuadratic.first_index);
        result = result && (MapPolicy(&map).next_index == MapPolicyQuadratic.next_index);
        result = result && (MapPolicy(&map).next_capacity == MapPolicyQuadratic.next_capacity);
        result = result && (MapPolicy(&map).should_rehash == MapPolicyQuadratic.should_rehash);
        result = result && (MapPolicy(&map).first_index == MapPolicyQuadratic.first_index);
        result = result && (MapPolicy(&map).next_index == MapPolicyQuadratic.next_index);
        result = result && (MapPolicy(&map).next_capacity == MapPolicyQuadratic.next_capacity);
        result = result && (MapPolicy(&map).should_rehash == MapPolicyQuadratic.should_rehash);
        // Tombstones gone, survivors intact, exact counts preserved.
        result = result && (MapPolicy(&map).next_index == MapPolicyQuadratic.next_index);
        result = result && (MapPolicy(&map).next_capacity == MapPolicyQuadratic.next_capacity);
        result = result && (MapPolicy(&map).should_rehash == MapPolicyQuadratic.should_rehash);
        // Tombstones gone, survivors intact, exact counts preserved.
        result = result && (MapTombstones(&map) == 0);
        MapRehashWithPolicy(&map, MapPairCount(&map), MapPolicyQuadratic);
    
        bool result = (MapPolicy(&map).first_index == MapPolicyQuadratic.first_index) &&
                      (MapPolicy(&map).next_index == MapPolicyQuadratic.next_index) &&
                      (MapPolicy(&map).next_capacity == MapPolicyQuadratic.next_capacity) &&
    
        bool result = (MapPolicy(&map).first_index == MapPolicyQuadratic.first_index) &&
                      (MapPolicy(&map).next_index == MapPolicyQuadratic.next_index) &&
                      (MapPolicy(&map).next_capacity == MapPolicyQuadratic.next_capacity) &&
                      (MapPolicy(&map).should_rehash == MapPolicyQuadratic.should_rehash);
        bool result = (MapPolicy(&map).first_index == MapPolicyQuadratic.first_index) &&
                      (MapPolicy(&map).next_index == MapPolicyQuadratic.next_index) &&
                      (MapPolicy(&map).next_capacity == MapPolicyQuadratic.next_capacity) &&
                      (MapPolicy(&map).should_rehash == MapPolicyQuadratic.should_rehash);
                      (MapPolicy(&map).next_index == MapPolicyQuadratic.next_index) &&
                      (MapPolicy(&map).next_capacity == MapPolicyQuadratic.next_capacity) &&
                      (MapPolicy(&map).should_rehash == MapPolicyQuadratic.should_rehash);
    
        for (int i = 0; i < 24; i++) {
        typedef Map(int, int) IntIntMap;
        DefaultAllocator alloc         = DefaultAllocatorInit();
        MapPolicy        custom_policy = {
                   .name            = "five-step",
                   .should_rehash   = custom_should_rehash,
    
        result = result && (MapCapacity(&map) == 10);
        result = result && (MapPolicy(&map).next_capacity == custom_next_capacity);
    
        for (int i = 0; i < 6; i++) {
        // Fresh MapInit installs the linear policy by value and starts with
        // an empty, unallocated probe table.
        bool result = (MapPolicy(&map).should_rehash == MapPolicyLinear.should_rehash) &&
                      (MapPolicy(&map).next_capacity == MapPolicyLinear.next_capacity) &&
                      (MapPolicy(&map).first_index == MapPolicyLinear.first_index) &&
        // an empty, unallocated probe table.
        bool result = (MapPolicy(&map).should_rehash == MapPolicyLinear.should_rehash) &&
                      (MapPolicy(&map).next_capacity == MapPolicyLinear.next_capacity) &&
                      (MapPolicy(&map).first_index == MapPolicyLinear.first_index) &&
                      (MapPolicy(&map).next_index == MapPolicyLinear.next_index) &&
        bool result = (MapPolicy(&map).should_rehash == MapPolicyLinear.should_rehash) &&
                      (MapPolicy(&map).next_capacity == MapPolicyLinear.next_capacity) &&
                      (MapPolicy(&map).first_index == MapPolicyLinear.first_index) &&
                      (MapPolicy(&map).next_index == MapPolicyLinear.next_index) &&
                      (MapPolicy(&map).max_probe_count == MapPolicyLinear.max_probe_count) && (MapPairCount(&map) == 0) &&
                      (MapPolicy(&map).next_capacity == MapPolicyLinear.next_capacity) &&
                      (MapPolicy(&map).first_index == MapPolicyLinear.first_index) &&
                      (MapPolicy(&map).next_index == MapPolicyLinear.next_index) &&
                      (MapPolicy(&map).max_probe_count == MapPolicyLinear.max_probe_count) && (MapPairCount(&map) == 0) &&
                      (MapCapacity(&map) == 0) && (MapTombstones(&map) == 0) && MapEmpty(&map);
                      (MapPolicy(&map).first_index == MapPolicyLinear.first_index) &&
                      (MapPolicy(&map).next_index == MapPolicyLinear.next_index) &&
                      (MapPolicy(&map).max_probe_count == MapPolicyLinear.max_probe_count) && (MapPairCount(&map) == 0) &&
                      (MapCapacity(&map) == 0) && (MapTombstones(&map) == 0) && MapEmpty(&map);
    }
    
    static MapPolicy make_tight_policy(void) {
        MapPolicy p       = {0};
        p.name            = "tight-linear";
    
    static MapPolicy make_tight_policy(void) {
        MapPolicy p       = {0};
        p.name            = "tight-linear";
        p.should_rehash   = policy_should_rehash;
    }
    
    static MapPolicy make_sabotage_policy(void) {
        MapPolicy p       = {0};
        p.name            = "sabotage-linear";
    
    static MapPolicy make_sabotage_policy(void) {
        MapPolicy p       = {0};
        p.name            = "sabotage-linear";
        p.should_rehash   = policy_should_rehash;
    }
    
    static MapPolicy make_small_probe_policy(void) {
        MapPolicy p       = {0};
        p.name            = "small-probe-linear";
    
    static MapPolicy make_small_probe_policy(void) {
        MapPolicy p       = {0};
        p.name            = "small-probe-linear";
        p.should_rehash   = policy_should_rehash;
    }
    
    static MapPolicy make_validate_only_reject_policy(void) {
        MapPolicy p       = {0};
        p.name            = "stuck-probe-huge-cap";
    
    static MapPolicy make_validate_only_reject_policy(void) {
        MapPolicy p       = {0};
        p.name            = "stuck-probe-huge-cap";
        p.should_rehash   = policy_should_rehash;
    }
    
    static MapPolicy fill_then_grow_policy(void) {
        MapPolicy policy = {
            .name            = "fill-then-grow",
    
    static MapPolicy fill_then_grow_policy(void) {
        MapPolicy policy = {
            .name            = "fill-then-grow",
            .should_rehash   = grow_only_from_empty,
    }
    
    static MapPolicy make_policy42(void) {
        MapPolicy policy = {
            .name            = "const42",
    
    static MapPolicy make_policy42(void) {
        MapPolicy policy = {
            .name            = "const42",
            .should_rehash   = policy42_should_rehash,
        MapInsertR(&map, 3, 30);
    
        MapPolicy bad = make_validate_only_reject_policy();
        MapRehashWithPolicy(&map, 1, bad); // real: LOG_FATAL on the stuck-probe check
        MapInsertR(&map, 3, 30);
    
        MapPolicy tight  = make_tight_policy();
        bool      result = MapRehashWithPolicy(&map, 0, tight);
            MapInsertR(&map, k, k * 10);
    
        MapPolicy sab = make_sabotage_policy();
        MapRehashWithPolicy(&map, 2, sab); // must LOG_FATAL "insufficient capacity"
        typedef Map(int, int) IntIntMap;
        DefaultAllocator alloc  = DefaultAllocatorInit();
        MapPolicy        policy = make_small_probe_policy();
        IntIntMap        map    = MapInitWithPolicy(i32_identity_hash, i32_compare, policy, &alloc);
        typedef Map(int, int) IntIntMap;
        DefaultAllocator alloc  = DefaultAllocatorInit();
        MapPolicy        policy = fill_then_grow_policy();
        IntIntMap        map    = MapInitWithPolicy(i32_hash, i32_compare, policy, &alloc);
        bool             result = true;
        typedef Map(int, int) IntIntMap;
        DefaultAllocator alloc  = DefaultAllocatorInit();
        MapPolicy        policy = {
                   .name            = "tight-linear",
                   .should_rehash   = load_rehash,
        typedef Map(int, int) IntIntMap;
        DefaultAllocator alloc  = DefaultAllocatorInit();
        MapPolicy        policy = make_policy42();
        IntIntMap        map    = MapInitWithPolicy(i32_hash, i32_compare, policy, &alloc);
        typedef Map(int, int) IntIntMap;
        DefaultAllocator alloc  = DefaultAllocatorInit();
        MapPolicy        policy = fill_then_grow_policy();
        IntIntMap        map    = MapInitWithPolicy(i32_hash, i32_compare, policy, &alloc);
                      MapEntries(&map) == NULL && MapStates(&map) == NULL && MapKeyCompare(&map) == i32_compare &&
                      MapValueCompare(&map) == NULL && MapKeyHash(&map) == i32_hash &&
                      MapPolicy(&map).should_rehash == MapPolicyLinear.should_rehash &&
                      MapPolicy(&map).next_capacity == MapPolicyLinear.next_capacity &&
                      MapPolicy(&map).first_index == MapPolicyLinear.first_index &&
                      MapValueCompare(&map) == NULL && MapKeyHash(&map) == i32_hash &&
                      MapPolicy(&map).should_rehash == MapPolicyLinear.should_rehash &&
                      MapPolicy(&map).next_capacity == MapPolicyLinear.next_capacity &&
                      MapPolicy(&map).first_index == MapPolicyLinear.first_index &&
                      MapPolicy(&map).next_index == MapPolicyLinear.next_index &&
                      MapPolicy(&map).should_rehash == MapPolicyLinear.should_rehash &&
                      MapPolicy(&map).next_capacity == MapPolicyLinear.next_capacity &&
                      MapPolicy(&map).first_index == MapPolicyLinear.first_index &&
                      MapPolicy(&map).next_index == MapPolicyLinear.next_index &&
                      MapPolicy(&map).max_probe_count == MapPolicyLinear.max_probe_count;
                      MapPolicy(&map).next_capacity == MapPolicyLinear.next_capacity &&
                      MapPolicy(&map).first_index == MapPolicyLinear.first_index &&
                      MapPolicy(&map).next_index == MapPolicyLinear.next_index &&
                      MapPolicy(&map).max_probe_count == MapPolicyLinear.max_probe_count;
                      MapPolicy(&map).first_index == MapPolicyLinear.first_index &&
                      MapPolicy(&map).next_index == MapPolicyLinear.next_index &&
                      MapPolicy(&map).max_probe_count == MapPolicyLinear.max_probe_count;
    
        MapDeinit(&map);
        typedef Map(int, int) IntIntMap;
        DefaultAllocator alloc         = DefaultAllocatorInit();
        MapPolicy        custom_policy = {
                   .name            = "custom-linear",
                   .should_rehash   = custom_should_rehash_snapshot,
        custom_policy.max_probe_count = 0;
    
        bool result = ZstrCompare(MapPolicy(&map).name, "custom-linear") == 0 &&
                      MapPolicy(&map).should_rehash == custom_should_rehash_snapshot &&
                      MapPolicy(&map).next_capacity == custom_next_capacity &&
    
        bool result = ZstrCompare(MapPolicy(&map).name, "custom-linear") == 0 &&
                      MapPolicy(&map).should_rehash == custom_should_rehash_snapshot &&
                      MapPolicy(&map).next_capacity == custom_next_capacity &&
                      MapPolicy(&map).first_index == custom_first_index &&
        bool result = ZstrCompare(MapPolicy(&map).name, "custom-linear") == 0 &&
                      MapPolicy(&map).should_rehash == custom_should_rehash_snapshot &&
                      MapPolicy(&map).next_capacity == custom_next_capacity &&
                      MapPolicy(&map).first_index == custom_first_index &&
                      MapPolicy(&map).next_index == custom_next_index && MapPolicy(&map).max_probe_count == 11;
                      MapPolicy(&map).should_rehash == custom_should_rehash_snapshot &&
                      MapPolicy(&map).next_capacity == custom_next_capacity &&
                      MapPolicy(&map).first_index == custom_first_index &&
                      MapPolicy(&map).next_index == custom_next_index && MapPolicy(&map).max_probe_count == 11;
                      MapPolicy(&map).next_capacity == custom_next_capacity &&
                      MapPolicy(&map).first_index == custom_first_index &&
                      MapPolicy(&map).next_index == custom_next_index && MapPolicy(&map).max_probe_count == 11;
    
        MapDeinit(&map);
    
    static bool test_validate_map_policy(void) {
        MapPolicy custom_policy = {
            .name            = "custom-linear",
            .should_rehash   = custom_should_rehash_snapshot,
        typedef Map(int, int) IntIntMap;
        DefaultAllocator alloc         = DefaultAllocatorInit();
        MapPolicy        custom_policy = {
                   .name            = "vcmp-policy",
                   .should_rehash   = custom_should_rehash_snapshot,
    
        bool result = MapKeyHash(&map) == i32_hash && MapKeyCompare(&map) == i32_compare &&
                      MapValueCompare(&map) == i32_compare && ZstrCompare(MapPolicy(&map).name, "vcmp-policy") == 0 &&
                      MapPolicy(&map).should_rehash == custom_should_rehash_snapshot &&
                      MapPolicy(&map).next_capacity == custom_next_capacity &&
        bool result = MapKeyHash(&map) == i32_hash && MapKeyCompare(&map) == i32_compare &&
                      MapValueCompare(&map) == i32_compare && ZstrCompare(MapPolicy(&map).name, "vcmp-policy") == 0 &&
                      MapPolicy(&map).should_rehash == custom_should_rehash_snapshot &&
                      MapPolicy(&map).next_capacity == custom_next_capacity &&
                      MapPolicy(&map).first_index == custom_first_index &&
                      MapValueCompare(&map) == i32_compare && ZstrCompare(MapPolicy(&map).name, "vcmp-policy") == 0 &&
                      MapPolicy(&map).should_rehash == custom_should_rehash_snapshot &&
                      MapPolicy(&map).next_capacity == custom_next_capacity &&
                      MapPolicy(&map).first_index == custom_first_index &&
                      MapPolicy(&map).next_index == custom_next_index && MapPolicy(&map).max_probe_count == 13;
                      MapPolicy(&map).should_rehash == custom_should_rehash_snapshot &&
                      MapPolicy(&map).next_capacity == custom_next_capacity &&
                      MapPolicy(&map).first_index == custom_first_index &&
                      MapPolicy(&map).next_index == custom_next_index && MapPolicy(&map).max_probe_count == 13;
                      MapPolicy(&map).next_capacity == custom_next_capacity &&
                      MapPolicy(&map).first_index == custom_first_index &&
                      MapPolicy(&map).next_index == custom_next_index && MapPolicy(&map).max_probe_count == 13;
    
        MapDeinit(&map);
    // (`>= 1`) enters the check and LOG_FATALs.
    static bool test_validate_policy_skips_stuck_check_at_probe_budget_one(void) {
        MapPolicy policy = {
            .name            = "stuck-budget-one",
            .should_rehash   = load_rehash,
    
    // Returns a baseline policy that passes validate_map_policy in full.
    static MapPolicy valid_baseline_policy(void) {
        MapPolicy policy = {
            .name            = "baseline",
    // Returns a baseline policy that passes validate_map_policy in full.
    static MapPolicy valid_baseline_policy(void) {
        MapPolicy policy = {
            .name            = "baseline",
            .should_rehash   = valid_should_rehash,
        WriteFmt("Testing ValidateMapPolicy without name\n");
    
        MapPolicy policy = valid_baseline_policy();
        policy.name      = "";
        WriteFmt("Testing ValidateMapPolicy without should_rehash\n");
    
        MapPolicy policy     = valid_baseline_policy();
        policy.should_rehash = NULL;
        WriteFmt("Testing ValidateMapPolicy without next_capacity\n");
    
        MapPolicy policy     = valid_baseline_policy();
        policy.next_capacity = NULL;
        WriteFmt("Testing ValidateMapPolicy without first_index\n");
    
        MapPolicy policy   = valid_baseline_policy();
        policy.first_index = NULL;
        WriteFmt("Testing ValidateMapPolicy without next_index\n");
    
        MapPolicy policy  = valid_baseline_policy();
        policy.next_index = NULL;
        WriteFmt("Testing ValidateMapPolicy without probe limit\n");
    
        MapPolicy policy       = valid_baseline_policy();
        policy.max_probe_count = 0;
        WriteFmt("Testing ValidateMapPolicy zero-capacity for non-empty snapshot\n");
    
        MapPolicy policy     = valid_baseline_policy();
        policy.next_capacity = zero_for_first_nonempty_snapshot;
        WriteFmt("Testing ValidateMapPolicy capacity smaller than length\n");
    
        MapPolicy policy     = valid_baseline_policy();
        policy.next_capacity = small_for_same_min;
        WriteFmt("Testing ValidateMapPolicy capacity smaller than min_entries\n");
    
        MapPolicy policy     = valid_baseline_policy();
        policy.next_capacity = small_for_more_min;
        WriteFmt("Testing ValidateMapPolicy first_index out of range\n");
    
        MapPolicy policy   = valid_baseline_policy();
        policy.first_index = out_of_range_first_index;
        WriteFmt("Testing ValidateMapPolicy next_index out of range\n");
    
        MapPolicy policy  = valid_baseline_policy();
        policy.next_index = out_of_range_next_index;
        WriteFmt("Testing ValidateMapPolicy stuck probe sequence\n");
    
        MapPolicy policy  = valid_baseline_policy();
        policy.next_index = stuck_next_index;
        typedef Map(int, int) IntIntMap;
        DefaultAllocator alloc  = DefaultAllocatorInit();
        MapPolicy        policy = valid_baseline_policy();
        policy.max_probe_count  = 0; // single broken field
    }
    
    static MapPolicy make_probe_policy(MapPolicyNextIndexFn next_index) {
        MapPolicy p = {
            .name            = "self-check-probe",
    
    static MapPolicy make_probe_policy(MapPolicyNextIndexFn next_index) {
        MapPolicy p = {
            .name            = "self-check-probe",
            .should_rehash   = poly_should_rehash,
        typedef Map(int, int) IntIntMap;
        DefaultAllocator alloc  = DefaultAllocatorInit();
        MapPolicy        policy = {
                   .name            = "trap-at-42",
                   .should_rehash   = poly_should_rehash,
        typedef Map(int, int) IntIntMap;
        DefaultAllocator alloc  = DefaultAllocatorInit();
        MapPolicy        policy = make_probe_policy(poly_next_index_stuck_at_cap8);
        IntIntMap        map    = MapInitWithPolicy(i32_hash, i32_compare, policy, &alloc); // must LOG_FATAL
        MapDeinit(&map);
        typedef Map(int, int) IntIntMap;
        DefaultAllocator alloc  = DefaultAllocatorInit();
        MapPolicy        policy = make_probe_policy(poly_next_index_stuck_at_golden);
        IntIntMap        map    = MapInitWithPolicy(i32_hash, i32_compare, policy, &alloc); // must LOG_FATAL
        MapDeinit(&map);
        typedef Map(int, int) IntIntMap;
        DefaultAllocator alloc  = DefaultAllocatorInit();
        MapPolicy        policy = make_probe_policy(poly_next_index_returns_first);
        IntIntMap        map    = MapInitWithPolicy(i32_hash, i32_compare, policy, &alloc); // must LOG_FATAL
        MapDeinit(&map);
        typedef Map(int, int) IntIntMap;
        DefaultAllocator alloc  = DefaultAllocatorInit();
        MapPolicy        policy = {
                   .name            = "wide-linear",
                   .should_rehash   = never_rehash,
        typedef Map(int, int) IntIntMap;
        DefaultAllocator alloc  = DefaultAllocatorInit();
        MapPolicy        policy = {
                   .name            = "shrinkable",
                   .should_rehash   = never_rehash,
    // never revisit -- so a quadratic-degraded-to-linear mutant makes some key
    // unreachable or returns a neighbour's value here.
    static bool run_collision_contract_cycle(MapPolicy policy) {
        enum {
            KEY_COUNT = 24
Last updated on