MapForeachPair
Description
Iterate over all stored key/value pairs by value.
Parameters
| Name | Direction | Description |
|---|---|---|
m |
in,out | Map to iterate over. |
key_var |
in | Name of variable bound to a copy of each pair’s key. |
value_var |
in | Name of variable bound to a copy of each pair’s value. |
Success
The loop body runs once per occupied slot with key_var and value_var bound to copies of the stored key and value. The body is skipped when m is empty. Mutating the locals does not write back into the map.
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)
- In
Foreach.c:98:
MapInsertR(&map, 2, 25);
MapForeachPair(&map, key, value) {
key_sum += key;
value_sum += value;- In
Foreach.c:111:
int key_sum_again = 0;
int value_sum_again = 0;
MapForeachPair(&map, key, value) {
key_sum_again += key;
value_sum_again += value;- In
Foreach.c:168:
n += 1;
}
MapForeachPair(&map, k, v) {
(void)k;
(void)v;
Last updated on