MapRetainIf
MapRetainIf
Description
Retain only entries that satisfy a predicate.
Parameters
| Name | Direction | Description |
|---|---|---|
m |
in,out | Map. |
predicate_fn |
in | Callback returning true for entries to keep. |
ctx |
in,out | Optional user context passed to the predicate. |
Success
Number of removed pairs.
Usage example (Cross-references)
Usage examples (Cross-references)
- In
Map.c:1113:
if (!predicate) {
LOG_FATAL("MapRetainIf requires a predicate");
}- In
Map.Ops.c:164:
MapInsertR(&map, 4, 40);
bool result = (MapRetainIf(&map, retain_values_above_threshold, &threshold) == 2);
result = result && !MapContainsKey(&map, 1);
result = result && !MapContainsKey(&map, 2);
Last updated on