Skip to content
MapMustInsertR

MapMustInsertR

Description

Aborting variant of MapInsertR. See that macro for parameter semantics and success-state effects.

Success

Returns to the caller. The underlying MapInsertR call succeeded; see MapInsertR for the post-state.

Failure

Does not return - aborts via LOG_FATAL / Abort when the underlying MapInsertR call returns false.

Usage example (Cross-references)

Usage examples (Cross-references)
        do {                                                                                                               \
            if (!MapInsertR((m), (in_key), (in_value))) {                                                                  \
                LOG_FATAL("MapMustInsertR failed");                                                                        \
            }                                                                                                              \
        } while (0)
        };
        for (int i = 0; i < N; i++)
            MapMustInsertR(&map, i, i * 7 + 1);
    
        bool result = (MapPairCount(&map) == N);
        result      = result && (MapValueCountForKey(&map, 1) == 1);
    
        MapMustInsertR(&map, 2, 20);
        result = result && (MapValueCountForKey(&map, 2) == 1);
        // Four keys colliding into one bucket form a single probe chain.
        for (int k = 0; k < 4; k++)
            MapMustInsertR(&map, k, k * 10);
    
        // Remove two interior keys; the ones before and after must stay reachable.
Last updated on