Skip to content
MapRemoveFirst

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)
        size padded         = live_rec->padded_size;
        self->bytes_in_use -= (u64)requested;
        MapRemoveFirst(&self->live, ptr);
    
        if (self->config.force_page_backing) {
        MapSetOnlyR(&map, 2, 20);
    
        bool result = MapRemoveFirst(&map, 1);
        result      = result && MapContainsKey(&map, 1);
        result      = result && (MapValueCountForKey(&map, 1) == 1);
        }
    
        MapRemoveFirst(&map, 5);
        MapSetOnlyR(&map, 105, 205);
        }
    
        MapRemoveFirst(&map, 5);
    
        bool result = (MapValuePtrFromCursor(&map, cursor) == NULL);
        MapInsertR(&map, 1, 11);
        MapInsertR(&map, 2, 20);
        MapRemoveFirst(&map, 1);
        MapClear(&map);
        MapInsertR(&first, 1, 11);
        MapInsertR(&first, 2, 20);
        MapRemoveFirst(&first, 1);
    
        MapInsertR(&second, 9, 90);
Last updated on