MapSetOnlyR
Description
Set the value for in_key, replacing any existing entries. R-value form.
Success
Returns true. Same state effects as MapSetOnlyL minus the source-zeroing step; both sources are left untouched.
Failure
Returns false on allocation failure. The map is unchanged.
Usage example (Cross-references)
Usage examples (Cross-references)
- In
Insert.h:574:
#define MapMustSetOnlyR(m, in_key, in_value) \
do { \
if (!MapSetOnlyR((m), (in_key), (in_value))) { \
LOG_FATAL("MapMustSetOnlyR failed"); \
} \- In
Ops.c:92:
int red_count = 0;
MapSetOnlyR(&map, "red", "apple");
MapInsertR(&map, "red", "cherry");
MapSetOnlyR(&map, "yellow", "banana");- In
Ops.c:94:
MapSetOnlyR(&map, "red", "apple");
MapInsertR(&map, "red", "cherry");
MapSetOnlyR(&map, "yellow", "banana");
MapSetOnlyR(&map, "green", "pear");
MapRehashWithPolicy(&map, MapPairCount(&map), MapPolicyQuadratic);- In
Ops.c:95:
MapInsertR(&map, "red", "cherry");
MapSetOnlyR(&map, "yellow", "banana");
MapSetOnlyR(&map, "green", "pear");
MapRehashWithPolicy(&map, MapPairCount(&map), MapPolicyQuadratic);- In
Init.c:73:
(MapPairCount(&map) == 0) && MapEmpty(&map) && !MapContainsKey(&map, 1) && !MapContainsKey(&map, 2);
MapSetOnlyR(&map, 7, 70);
result = result && (MapPairCount(&map) == 1) && (MapValueCountForKey(&map, 7) == 1);
result = result && MapGetFirstPtr(&map, 7) && (*MapGetFirstPtr(&map, 7) == 70);- In
Init.c:88:
for (int i = 0; i < 24; i++) {
MapSetOnlyR(&map, i, i * 10);
}- In
Init.c:123:
for (int i = 0; i < 6; i++) {
MapSetOnlyR(&map, i, i + 100);
}- In
Init.c:166:
for (i = 0; i < 8; i++)
MapSetOnlyR(&map, i, i * 100);
// Force a growth-driven rehash. Existing entries must survive it,
- In
Insert.c:347:
MapInsertR(&map, 1, 11);
MapInsertR(&map, 2, 20);
MapSetOnlyR(&map, 2, 200);
MapSetOnlyR(&map, 3, 30);- In
Insert.c:348:
MapInsertR(&map, 2, 20);
MapSetOnlyR(&map, 2, 200);
MapSetOnlyR(&map, 3, 30);
bool result = MapPairCount(&map) == 4;- In
Insert.c:428:
bool result = (MapValueCountForKey(&map, 5) == 3);
MapSetOnlyR(&map, 5, 500);
result = result && (MapValueCountForKey(&map, 5) == 1);- In
Insert.c:1159:
bool result = (MapTombstones(&map) == 0);
MapSetOnlyR(&map, 7, 700); // remove-all (tomb=1) then raw reinsert into the tombstone
result = result && (MapTombstones(&map) == 0);- In
Remove.c:39:
IntIntMap map = MapInit(i32_hash, i32_compare, &alloc);
MapSetOnlyR(&map, 1, 10);
MapInsertR(&map, 1, 11);
MapSetOnlyR(&map, 2, 20);- In
Remove.c:41:
MapSetOnlyR(&map, 1, 10);
MapInsertR(&map, 1, 11);
MapSetOnlyR(&map, 2, 20);
u64 length_before = MapPairCount(&map);- In
Remove.c:296:
for (int i = 0; i < 12; i++)
MapSetOnlyR(&map, i, i + 100);
u64 length_before = MapPairCount(&map);- In
Remove.c:304:
result = result && (MapPairCount(&map) == length_before - 1);
MapSetOnlyR(&map, 5, 205);
result = result && MapContainsKey(&map, 5);
result = result && MapGetFirstPtr(&map, 5) && (*MapGetFirstPtr(&map, 5) == 205);- In
Foreach.c:29:
for (int i = 1; i <= 4; i++) {
MapSetOnlyR(&map, i, i * 10);
}
MapInsertR(&map, 2, 25);- In
Foreach.c:95:
for (int i = 1; i <= 4; i++)
MapSetOnlyR(&map, i, i * 10);
MapInsertR(&map, 2, 25);- In
Access.c:148:
IntIntMap map = MapInitWithValueCompare(i32_hash, i32_compare, i32_compare, &alloc);
MapSetOnlyR(&map, 7, 70);
MapInsertR(&map, 7, 71);
MapSetOnlyR(&map, 9, 90);- In
Access.c:150:
MapSetOnlyR(&map, 7, 70);
MapInsertR(&map, 7, 71);
MapSetOnlyR(&map, 9, 90);
bool result = MapContainsKey(&map, 7);- In
Access.c:173:
IntIntMap map = MapInit(i32_hash, i32_compare, &alloc);
MapSetOnlyR(&map, 11, 110);
MapInsertR(&map, 11, 111);- In
Access.c:193:
IntIntMap map = MapInitWithValueCompare(i32_hash, i32_compare, i32_compare, &alloc);
MapSetOnlyR(&map, 11, 110);
MapInsertR(&map, 11, 111);- In
Access.c:250:
IntIntMap map = MapInit(i32_hash, i32_compare, &alloc);
MapSetOnlyR(&map, 11, 110);
MapInsertR(&map, 11, 111);
Last updated on