Skip to content
MapForeachValuePtr

MapForeachValuePtr

Description

Iterate over all stored values with pointers.

Parameters

Name Direction Description
m in,out Map to iterate over.
value_ptr in Name of pointer variable bound to each stored value.

Success

The loop body runs once per occupied slot with value_ptr bound to the in-slot value address. Use this form when the body mutates the stored value in place. The body is skipped when m is empty.

Failure

The macro itself does not fail. LOG_FATAL via ValidateMap(m) when m is uninitialised or corrupted.

Usage example (Cross-references)

Usage examples (Cross-references)
    
        int before_sum = 0;
        MapForeachValuePtr(&map, value_ptr) {
            before_sum += *value_ptr;
            *value_ptr += 5; // mutate every value in place
            n += 1;
        }
        MapForeachValuePtr(&map, vp) {
            (void)vp;
            n += 1;
Last updated on