Skip to content
MapValuePtrFromCursor

MapValuePtrFromCursor

Description

Get value pointer for a valid cursor.

Parameters

Name Direction Description
m in,out Map.
cursor in,out Valid cursor for this map.

Success

Returns a pointer of type MAP_VALUE_TYPE(m) * to the value slot referenced by the cursor. The map is not modified. The pointer is valid until the next rehash.

Failure

Returns NULL if the cursor is invalid or no longer points to an occupied entry (e.g. after a rehash). The map is not modified.

Usage example (Cross-references)

Usage examples (Cross-references)
        cursor = MapFindFirstForKey(&map, 4);
        while (MapValueCursorIsValid(cursor)) {
            int *value_ptr = MapValuePtrFromCursor(&map, cursor);
            if (!value_ptr) {
                MapDeinit(&map);
        bool result = (seen == 3) && (value_sum == (40 + 41 + 42));
        result      = result && !MapValueCursorIsValid(MapFindFirstForKey(&map, 99));
        result      = result && (MapValuePtrFromCursor(&map, MapValueCursorInvalid()) == NULL);
    
        MapDeinit(&map);
        MapRemoveFirst(&map, 5);
    
        bool result = (MapValuePtrFromCursor(&map, cursor) == NULL);
        result      = result && (MapValueCountForKey(&map, 5) == 1);
        result      = result && MapGetFirstPtr(&map, 5) && (*MapGetFirstPtr(&map, 5) == 51);
Last updated on