Add hashmap_ensure() function
A common pattern is:
item = hashmap_get(map, &lookup);
if (!item) {
hashmap_set(map, &new_item);
item = hashmap_get(map, &lookup);
}
Could you implement something like:
void *hashmap_ensure(struct hashmap *map, const void *item);
which returns the existing item if present, otherwise inserts it and returns the newly inserted item?
Add
hashmap_ensure()functionA common pattern is:
Could you implement something like:
which returns the existing item if present, otherwise inserts it and returns the newly inserted item?