hfind_ptr¶
Category: hash
GitHub: cute_hashtable.h
Fetches a pointer to the item that k
maps to.
Parameters | Description |
---|---|
h | The hashtable. Can be NULL . Needs to be a pointer to the type of items in the table. |
k | The key for lookups. Each {key, item} pair must be unique. Keys are always typecasted to uint64_t e.g. you can use pointers as keys. |
Return Value¶
Returns a pointer to an item. Returns NULL
if not found.
Code Example¶
Set and get a few elements from a hashtable.
htbl CF_V2 table = NULL;
hadd(table, 10, cf_v2(-1, 1));
CF_V2 v = hfind_ptr(table, 10);
CF_ASSERT(v);
CF_ASSERT(v->x == -1);
CF_ASSERT(v->y == 1);
hfree(table);
Remarks¶
If you want to fetch an item by value, you can use hget or hfind. Does the same thing as hget_ptr.
Related Pages¶
htbl
hset
hadd
hget
hfind
hget_ptr
hfree
hhas
hdel
hclear
hkeys
hitems
hswap
hsize
hcount