Skip to content
MapRehashWithPolicy

MapRehashWithPolicy

Description

Remap using a specific probing policy.

Parameters

Name Direction Description
m in,out Hash map.
n in Minimum number of entries expected after rehash.

Success

Returns true. The map is rebuilt with the new probing policy (copied into the map by value), sized to fit at least n entries plus the current length. Every live entry has been re-hashed under the new policy; tombstones are gone.

Failure

Returns false on allocation failure during the new probe table build. The map and its existing policy are unchanged.

Usage example (Cross-references)

Usage examples (Cross-references)
        }
    
        MapRehashWithPolicy(&map, MapPairCount(&map), MapPolicyQuadratic);
    
        bool result = (MapPolicy(&map).first_index == MapPolicyQuadratic.first_index) &&
        MapSetOnlyR(&map, "yellow", "banana");
        MapSetOnlyR(&map, "green", "pear");
        MapRehashWithPolicy(&map, MapPairCount(&map), MapPolicyQuadratic);
    
        bool result = (MapPolicy(&map).first_index == MapPolicyQuadratic.first_index) &&
    #define MapMustRehashWithPolicy(m, n, policy_value)                                                                    \
        do {                                                                                                               \
            if (!MapRehashWithPolicy((m), (n), (policy_value))) {                                                          \
                LOG_FATAL("MapMustRehashWithPolicy failed");                                                               \
            }                                                                                                              \
Last updated on