MapValueCountForKey
Description
Count how many values are stored for a key.
Parameters
| Name | Direction | Description |
|---|---|---|
m |
in | Map. |
lookup_key |
in | Key to search for. |
Success
Returns the number of entries mapping lookup_key to any value. The map is not modified.
Failure
Returns 0 when no entry exists for the key. The map is not modified.
Usage example (Cross-references)
Usage examples (Cross-references)
- In
Ops.c:62:
result = result && MapContainsKey(&map, "alpha");
result = result && !MapContainsKey(&map, key);
result = result && (MapValueCountForKey(&map, "alpha") == 2);
stored_value = MapGetFirstPtr(&map, "alpha");
result = result && stored_value && (*stored_value != value) && (ZstrCompare(*stored_value, "first") == 0);- In
Ops.c:102:
(MapPolicy(&map).next_capacity == MapPolicyQuadratic.next_capacity) &&
(MapPolicy(&map).should_rehash == MapPolicyQuadratic.should_rehash);
result = result && (MapValueCountForKey(&map, "red") == 2);
result = result && MapGetFirstPtr(&map, "red") && (ZstrCompare(*MapGetFirstPtr(&map, "red"), "apple") == 0);
result = result && MapGetFirstPtr(&map, "yellow") && (ZstrCompare(*MapGetFirstPtr(&map, "yellow"), "banana") == 0);- In
Ops.c:258:
result = result && MapContainsPair(&map, 2, 21);
result = result && MapContainsPair(&map, 3, 30);
result = result && (MapValueCountForKey(&map, 2) == 2);
result = result && (MapPairCount(&map) == 3);
result = result && (MapUniqueKeyCount(&map) == 2);- In
Ops.c:309:
int *v = MapGetFirstPtr(&map, 0);
bool result = v && (*v == 999);
result = result && (MapValueCountForKey(&map, 0) == 1);
MapDeinit(&map);- In
Init.c:74:
MapSetOnlyR(&map, 7, 70);
result = result && (MapPairCount(&map) == 1) && (MapValueCountForKey(&map, 7) == 1);
result = result && MapGetFirstPtr(&map, 7) && (*MapGetFirstPtr(&map, 7) == 70);- In
Insert.c:351:
bool result = MapPairCount(&map) == 4;
result = result && (MapValueCountForKey(&map, 1) == 2);
result = result && (MapValueCountForKey(&map, 2) == 1);
result = result && (MapValueCountForKey(&map, 3) == 1);- In
Insert.c:352:
bool result = MapPairCount(&map) == 4;
result = result && (MapValueCountForKey(&map, 1) == 2);
result = result && (MapValueCountForKey(&map, 2) == 1);
result = result && (MapValueCountForKey(&map, 3) == 1);
result = result && MapGetFirstPtr(&map, 1) && (*MapGetFirstPtr(&map, 1) == 10);- In
Insert.c:353:
result = result && (MapValueCountForKey(&map, 1) == 2);
result = result && (MapValueCountForKey(&map, 2) == 1);
result = result && (MapValueCountForKey(&map, 3) == 1);
result = result && MapGetFirstPtr(&map, 1) && (*MapGetFirstPtr(&map, 1) == 10);
result = result && MapGetFirstPtr(&map, 2) && (*MapGetFirstPtr(&map, 2) == 200);- In
Insert.c:374:
bool result = (MapPairCount(&map) == 3);
result = result && (MapValueCountForKey(&map, 1) == 3);
result = result && MapGetFirstPtr(&map, 1) && (*MapGetFirstPtr(&map, 1) == 100);
result = result && MapContainsPair(&map, 1, 11);- In
Insert.c:404:
result = result && !MapSetFirstR(&map, 7, 70);
result = result && !MapContainsKey(&map, 7);
result = result && (MapValueCountForKey(&map, 7) == 0);
result = result && (MapPairCount(&map) == 1);
// Pre-existing entry is untouched.
- In
Insert.c:426:
MapInsertR(&map, 5, 51);
MapInsertR(&map, 5, 52);
bool result = (MapValueCountForKey(&map, 5) == 3);
MapSetOnlyR(&map, 5, 500);- In
Insert.c:430:
MapSetOnlyR(&map, 5, 500);
result = result && (MapValueCountForKey(&map, 5) == 1);
result = result && MapGetFirstPtr(&map, 5) && (*MapGetFirstPtr(&map, 5) == 500);
result = result && MapContainsPair(&map, 5, 500);- In
Insert.c:453:
bool result = (key == 0) && (value == 0);
result = result && (MapValueCountForKey(&map, 42) == 1);
result = result && MapGetFirstPtr(&map, 42) && (*MapGetFirstPtr(&map, 42) == 84);- In
Insert.c:475:
bool result = (key == 42) && (value == 84);
result = result && (MapValueCountForKey(&map, 42) == 1);
result = result && MapGetFirstPtr(&map, 42) && (*MapGetFirstPtr(&map, 42) == 84);- In
Insert.c:497:
bool result = (key == 0) && (value == 0);
result = result && (MapValueCountForKey(&map, 11) == 1);
result = result && MapGetFirstPtr(&map, 11) && (*MapGetFirstPtr(&map, 11) == 110);- In
Insert.c:521:
bool result = MapSetFirstL(&map, 11, value);
result = result && (value == 0);
result = result && (MapValueCountForKey(&map, 11) == 1);
result = result && MapGetFirstPtr(&map, 11) && (*MapGetFirstPtr(&map, 11) == 110);- In
Insert.c:580:
result = value_ptr && (*value_ptr == 80);
result = result && (MapPairCount(&map) == 1);
result = result && (MapValueCountForKey(&map, 8) == 1);
value_ptr = MapEnsurePtr(&map, 8, 800);- In
Insert.c:585:
result = result && value_ptr && (*value_ptr == 80);
result = result && (MapPairCount(&map) == 1);
result = result && (MapValueCountForKey(&map, 8) == 1);
MapDeinit(&map);- In
Insert.c:608:
result = result && refetched && (*refetched == 333);
// Mutation must not have spawned a second entry.
result = result && (MapValueCountForKey(&map, 3) == 1);
result = result && (MapPairCount(&map) == 1);- In
Insert.c:630:
MapInsert(&map, k1, v1);
bool result = (k1 == 0) && (v1 == 0);
result = result && (MapValueCountForKey(&map, 1) == 1);
// MapSet aliases MapSetOnlyL: replace + zero both sources.
- In
Insert.c:634:
// MapSet aliases MapSetOnlyL: replace + zero both sources.
MapInsertR(&map, 1, 99); // give key 1 a second value
result = result && (MapValueCountForKey(&map, 1) == 2);
int k2 = 1;
MapSet(&map, k2, v2);- In
Insert.c:638:
MapSet(&map, k2, v2);
result = result && (k2 == 0) && (v2 == 0);
result = result && (MapValueCountForKey(&map, 1) == 1);
result = result && MapGetFirstPtr(&map, 1) && (*MapGetFirstPtr(&map, 1) == 11);- In
Insert.c:658:
MapMustInsertL(&map, k, v); // L-form zeroes sources
bool result = (k == 0) && (v == 0);
result = result && (MapValueCountForKey(&map, 1) == 1);
MapMustInsertR(&map, 2, 20);- In
Insert.c:661:
MapMustInsertR(&map, 2, 20);
result = result && (MapValueCountForKey(&map, 2) == 1);
int ik = 3;- In
Insert.c:667:
MapMustInsert(&map, ik, iv); // aliases L-form: zeroes both sources
result = result && (ik == 0) && (iv == 0);
result = result && (MapValueCountForKey(&map, 3) == 1);
// SetFirstR updates the existing first value of key 2 (insert was 20).
- In
Insert.c:679:
MapMustSetOnlyR(&map, 4, 40);
result = result && (MapValueCountForKey(&map, 4) == 1);
result = result && MapGetFirstPtr(&map, 4) && (*MapGetFirstPtr(&map, 4) == 40);- In
Insert.c:686:
MapMustSetOnlyL(&map, sk, so); // replace + zero both sources
result = result && (sk == 0) && (so == 0);
result = result && (MapValueCountForKey(&map, 4) == 1);
result = result && MapGetFirstPtr(&map, 4) && (*MapGetFirstPtr(&map, 4) == 50);- In
Insert.c:693:
MapMustSet(&map, msk, msv); // aliases SetOnlyL: zeroes both sources
result = result && (msk == 0) && (msv == 0);
result = result && (MapValueCountForKey(&map, 5) == 1);
result = result && MapGetFirstPtr(&map, 5) && (*MapGetFirstPtr(&map, 5) == 55);- In
Insert.c:1163:
result = result && (MapTombstones(&map) == 0);
result = result && (MapPairCount(&map) == 1);
result = result && (MapValueCountForKey(&map, 7) == 1);
result = result && MapGetFirstPtr(&map, 7) && (*MapGetFirstPtr(&map, 7) == 700);- In
Remove.c:47:
bool result = MapRemoveFirst(&map, 1);
result = result && MapContainsKey(&map, 1);
result = result && (MapValueCountForKey(&map, 1) == 1);
result = result && MapGetFirstPtr(&map, 1) && (*MapGetFirstPtr(&map, 1) == 11);
result = result && (MapPairCount(&map) == 2);- In
Remove.c:97:
result = result && !MapContainsPair(&map, 5, 51);
result = result && MapContainsPair(&map, 5, 52);
result = result && (MapValueCountForKey(&map, 5) == 2);
MapDeinit(&map);- In
Remove.c:223:
bool result = (MapRemoveIf(&map, remove_even_values, NULL) == 2);
result = result && !MapContainsKey(&map, 2);
result = result && (MapValueCountForKey(&map, 1) == 1);
result = result && MapGetFirstPtr(&map, 1) && (*MapGetFirstPtr(&map, 1) == 11);
result = result && MapContainsKey(&map, 3);- In
Remove.c:245:
bool result = (MapRemoveAll(&map, 5) == 3);
result = result && !MapContainsKey(&map, 5);
result = result && (MapValueCountForKey(&map, 5) == 0);
result = result && MapContainsKey(&map, 9);
result = result && (MapPairCount(&map) == 1);- In
Access.c:101:
MapInsertR(&map, 0, 7777);
bool result = (MapValueCountForKey(&map, 0) == 2);
MapDeinit(&map);- In
Access.c:158:
result = result && MapContainsPair(&map, 7, 71);
result = result && !MapContainsPair(&map, 7, 72);
result = result && (MapValueCountForKey(&map, 7) == 2);
result = result && (MapValueCountForKey(&map, 9) == 1);
result = result && (MapValueCountForKey(&map, 8) == 0);- In
Access.c:159:
result = result && !MapContainsPair(&map, 7, 72);
result = result && (MapValueCountForKey(&map, 7) == 2);
result = result && (MapValueCountForKey(&map, 9) == 1);
result = result && (MapValueCountForKey(&map, 8) == 0);
result = result && (MapUniqueKeyCount(&map) == 2);- In
Access.c:160:
result = result && (MapValueCountForKey(&map, 7) == 2);
result = result && (MapValueCountForKey(&map, 9) == 1);
result = result && (MapValueCountForKey(&map, 8) == 0);
result = result && (MapUniqueKeyCount(&map) == 2);- In
Access.c:225:
result = result && !MapContainsKey(&map, 7); // map_contains early-out
result = result && !MapContainsPair(&map, 7, 0); // map_contains_pair early-out
result = result && (MapValueCountForKey(&map, 7) == 0); // map_value_count early-out
result = result && (MapUniqueKeyCount(&map) == 0);
result = result && (MapPairCount(&map) == 0);- In
Access.c:330:
bool result = (MapValuePtrFromCursor(&map, cursor) == NULL);
result = result && (MapValueCountForKey(&map, 5) == 1);
result = result && MapGetFirstPtr(&map, 5) && (*MapGetFirstPtr(&map, 5) == 51);- In
Access.c:356:
int *v = MapGetFirstPtr(&map, k);
result = result && v && (*v == k * 100 + 7);
result = result && MapContainsKey(&map, k) && (MapValueCountForKey(&map, k) == 1);
}
// A key that collides into the chain but was never inserted is absent.
- In
Access.c:364:
// per-bucket.
MapInsertR(&map, 3, 999);
result = result && (MapValueCountForKey(&map, 3) == 2);
result = result && (MapValueCountForKey(&map, 4) == 1);
result = result && MapContainsPair(&map, 3, 307) && MapContainsPair(&map, 3, 999);- In
Access.c:365:
MapInsertR(&map, 3, 999);
result = result && (MapValueCountForKey(&map, 3) == 2);
result = result && (MapValueCountForKey(&map, 4) == 1);
result = result && MapContainsPair(&map, 3, 307) && MapContainsPair(&map, 3, 999);
result = result && !MapContainsPair(&map, 4, 999);- In
Access.c:405:
int *v = MapGetFirstPtr(&map, k);
result = result && v && (*v == k * 100 + 7);
result = result && MapContainsKey(&map, k) && (MapValueCountForKey(&map, k) == 1);
}
// A key that collides into the chain but was never inserted is absent.
- In
Access.c:426:
int *v = MapGetFirstPtr(&map, k);
result = result && v && (*v == k * 100 + 7);
result = result && MapContainsKey(&map, k) && (MapValueCountForKey(&map, k) == 1);
}
Last updated on