cf_map_get¶
Category: map
GitHub: cute_map.h
Fetches the item that k maps to.
| Parameters | Description |
|---|---|
m |
The map. Can be NULL. Must be declared with CF_MAP(T). |
k |
The key for lookups. Keys are always typecast to uint64_t. |
Return Value¶
Returns the item by value. If the key doesn't exist, returns a zero'd item.
Code Example¶
Set and get a few elements from a map.
CF_MAP(int) table = NULL;
map_set(table, 0, 5);
map_set(table, 1, 12);
CF_ASSERT(map_get(table, 0) == 5);
CF_ASSERT(map_get(table, 1) == 12);
map_free(table);
Remarks¶
Items are returned by value, not pointer. If you want a pointer (to check for NULL when the item
doesn't exist), use map_get_ptr. You can also call map_has to check existence.
Related Pages¶
CF_MAP
cf_map_set
cf_map_get_ptr
cf_map_has
cf_map_del
cf_map_clear
cf_map_keys
cf_map_items
cf_map_swap
cf_map_size
cf_map_free