Skip to content

MapKeyCompare

Description

Key-comparison callback installed at MapInit. Same shape as the GenericCompare callbacks Map / Vec accept elsewhere.

Parameters

Name Direction Description
m in Map.

Usage example (Cross-references)

Usage examples (Cross-references)
        MapInsertR(&map, 6, 60);
    
        bool result = (MapKeyHash(&map) == i32_hash) && (MapKeyCompare(&map) == i32_compare) && (MapPairCount(&map) == 2);
        result      = result && MapGetFirstPtr(&map, 5) && (*MapGetFirstPtr(&map, 5) == 50);
        result      = result && MapGetFirstPtr(&map, 6) && (*MapGetFirstPtr(&map, 6) == 60);
    
        bool result = MapPairCount(&map) == 0 && MapCapacity(&map) == 0 && MapTombstones(&map) == 0 &&
                      MapEntries(&map) == NULL && MapStates(&map) == NULL && MapKeyCompare(&map) == i32_compare &&
                      MapValueCompare(&map) == NULL && MapKeyHash(&map) == i32_hash &&
                      MapPolicy(&map).should_rehash == MapPolicyLinear.should_rehash &&
    
        bool result =
            MapKeyCompare(&map) == i32_compare && MapValueCompare(&map) == i32_compare && MapKeyHash(&map) == i32_hash;
    
        MapDeinit(&map);
        IntIntMap map = MapInitWithValueCompareAndPolicy(i32_hash, i32_compare, i32_compare, custom_policy, &alloc);
    
        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 &&
        );
    
        bool result = MapKeyHash(&map) == (GenericHash)zstr_hash && MapKeyCompare(&map) == (GenericCompare)zstr_compare &&
                      MapValueCompare(&map) == NULL && MapKeyCopyInit(&map) == (GenericCopyInit)zstr_init_clone &&
                      MapKeyCopyDeinit(&map) == (GenericCopyDeinit)zstr_deinit &&
Last updated on