Skip to content
MapGetFirstPtr

MapGetFirstPtr

MapGetFirstPtr

Description

Get pointer to the first value stored for a key.

Parameters

Name Direction Description
m in,out Map.
key in Key to search for.

Success

Pointer to the first value stored for the key.

Failure

NULL

Usage example (Cross-references)

Usage examples (Cross-references)
        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);
        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);
        result      = result && (MapPairCount(&map) == 2);
        bool result = !MapContainsKey(&map, 5);
        result      = result && MapContainsKey(&map, 105);
        result      = result && MapGetFirstPtr(&map, 105) && (*MapGetFirstPtr(&map, 105) == 205);
    
        MapDeinit(&map);
        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);
        result      = result && MapGetFirstPtr(&map, 3) && (*MapGetFirstPtr(&map, 3) == 30);
        result      = result && (MapValueCountForKey(&map, 3) == 1);
        result      = result && MapGetFirstPtr(&map, 1) && (*MapGetFirstPtr(&map, 1) == 10);
        result      = result && MapGetFirstPtr(&map, 2) && (*MapGetFirstPtr(&map, 2) == 200);
        result      = result && MapGetFirstPtr(&map, 3) && (*MapGetFirstPtr(&map, 3) == 30);
        result      = result && MapGetFirstPtr(&map, 1) && (*MapGetFirstPtr(&map, 1) == 10);
        result      = result && MapGetFirstPtr(&map, 2) && (*MapGetFirstPtr(&map, 2) == 200);
        result      = result && MapGetFirstPtr(&map, 3) && (*MapGetFirstPtr(&map, 3) == 30);
    
        MapDeinit(&map);
        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);
        result      = result && MapContainsPair(&map, 1, 12);
        bool result = (key == 0) && (value == 0);
        result      = result && (MapValueCountForKey(&map, 42) == 1);
        result      = result && MapGetFirstPtr(&map, 42) && (*MapGetFirstPtr(&map, 42) == 84);
    
        MapDeinit(&map);
        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);
        MapForeachValueForKey(&map, "alpha", entry_value) {
                      (map.policy.should_rehash == MisraMapPolicyQuadratic.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);
        result = result && MapGetFirstPtr(&map, "green") && (ZstrCompare(*MapGetFirstPtr(&map, "green"), "pear") == 0);
        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);
        result = result && MapGetFirstPtr(&map, "green") && (ZstrCompare(*MapGetFirstPtr(&map, "green"), "pear") == 0);
        MapForeachValueForKey(&map, "red", red_value) {
        result = result && MapGetFirstPtr(&map, "red") && (ZstrCompare(*MapGetFirstPtr(&map, "red"), "apple") == 0);
        result = result && MapGetFirstPtr(&map, "yellow") && (ZstrCompare(*MapGetFirstPtr(&map, "yellow"), "banana") == 0);
        result = result && MapGetFirstPtr(&map, "green") && (ZstrCompare(*MapGetFirstPtr(&map, "green"), "pear") == 0);
        MapForeachValueForKey(&map, "red", red_value) {
            if ((ZstrCompare(red_value, "apple") == 0) || (ZstrCompare(red_value, "cherry") == 0)) {
    
        for (int i = 0; i < 24; i++) {
            int *value = MapGetFirstPtr(&map, i);
            result     = result && value && (*value == i * 10);
        }
    
        for (int i = 0; i < 6; i++) {
            int *value = MapGetFirstPtr(&map, i);
            result     = result && value && (*value == (i + 100));
        }
        MapInsertR(&map, 11, 111);
    
        int *value  = MapGetFirstPtr(&map, 11);
        bool result = value && (*value == 110);
        result      = result && (MapGetFirstPtr(&map, 999) == NULL);
        int *value  = MapGetFirstPtr(&map, 11);
        bool result = value && (*value == 110);
        result      = result && (MapGetFirstPtr(&map, 999) == NULL);
    
        MapDeinit(&map);
Last updated on