MapRemoveFirst
Description
Remove and destroy the first entry matching a key.
Parameters
| Name | Direction | Description |
|---|---|---|
m |
in,out | Map. |
lookup_key |
in | Key to remove. |
Success
Returns true. The first matching entry has been removed; its slot is now a tombstone, and key_copy_deinit / value_copy_deinit (if configured) have been invoked on the removed key and value. Map length shrinks by one.
Failure
Returns false when no entry exists for the key. The map is not modified.
Usage example (Cross-references)
Usage examples (Cross-references)
- In
Debug.c:379:
size padded = live_rec->padded_size;
self->bytes_in_use -= (u64)requested;
MapRemoveFirst(&self->live, ptr);
if (self->config.force_page_backing) {- In
Ops.c:127:
MapInsertR(&first, 1, 11);
MapInsertR(&first, 2, 20);
MapRemoveFirst(&first, 1);
MapInsertR(&second, 9, 90);- In
Ops.c:180:
// Removing one of two pairs must keep it non-empty.
MapRemoveFirst(&map, 1);
result = result && !MapEmpty(&map);- In
Ops.c:184:
// Removing the last pair must make it empty again.
MapRemoveFirst(&map, 2);
result = result && MapEmpty(&map);
result = result && (MapPairCount(&map) == 0);- In
Ops.c:211:
MapInsertR(&map, 2, 20);
MapInsertR(&map, 3, 30);
MapRemoveFirst(&map, 2);
bool result = (MapTombstones(&map) == 1);- In
Ops.c:241:
MapInsertR(&map, 2, 21);
MapInsertR(&map, 3, 30);
MapRemoveFirst(&map, 1);
bool result = (MapTombstones(&map) == 1);- In
Init.c:67:
MapInsertR(&map, 1, 11);
MapInsertR(&map, 2, 20);
MapRemoveFirst(&map, 1);
MapClear(&map);- In
Insert.c:978:
MapInsertR(&map, 7, 70);
MapRemoveFirst(&map, 7);
bool result = (MapTombstones(&map) == 1);- In
Insert.c:999:
g_value_copy_should_fail = false;
bool result = MapInsertR(&map, 5, 50);
MapRemoveFirst(&map, 5);
result = result && (MapTombstones(&map) == 1);- In
Remove.c:45:
u64 length_before = MapPairCount(&map);
bool result = MapRemoveFirst(&map, 1);
result = result && MapContainsKey(&map, 1);
result = result && (MapValueCountForKey(&map, 1) == 1);- In
Remove.c:73:
u64 tombstones_before = MapTombstones(&map);
bool result = !MapRemoveFirst(&map, 99);
result = result && (MapPairCount(&map) == length_before);
result = result && (MapTombstones(&map) == tombstones_before);- In
Remove.c:164:
bool result = (MapTombstones(&map) == 0);
MapRemoveFirst(&map, 5);
result = result && (MapTombstones(&map) == 1);
result = result && !MapContainsKey(&map, 5);- In
Remove.c:300:
u64 length_before = MapPairCount(&map);
MapRemoveFirst(&map, 5);
bool result = !MapContainsKey(&map, 5);
result = result && (MapPairCount(&map) == length_before - 1);- In
Remove.c:351:
// Exercise every removal path against the deep-copy map.
result = result && MapRemoveFirst(&map, "alpha"); // one clone pair freed
result = result && MapRemovePair(&map, "alpha", "two"); // remaining alpha freed
result = result && (MapRemoveAll(&map, "beta") == 1); // beta freed
- In
Remove.c:385:
// Remove two interior keys; the ones before and after must stay reachable.
bool result = MapRemoveFirst(&map, 1) && MapRemoveFirst(&map, 2);
result = result && (MapPairCount(&map) == 2);
result = result && !MapContainsKey(&map, 1) && !MapContainsKey(&map, 2);- In
Access.c:133:
bool ok = MapValueCursorIsValid(cursor);
MapRemoveFirst(&map, 10);
MapRehashWithPolicy(&map, 5, policy);- In
Access.c:327:
}
MapRemoveFirst(&map, 5);
bool result = (MapValuePtrFromCursor(&map, cursor) == NULL);- In
Access.c:412:
// Remove an INTERIOR key from the collision chain.
const int removed = KEY_COUNT / 2;
MapRemoveFirst(&map, removed);
// Count dropped by exactly one; the removed key is gone.
Last updated on