Go to the source code of this file.
|
unordered_map | unordered_map_init (size_t key_size, size_t value_size, unsigned long(*hash)(const void *const key), int(*comparator)(const void *const one, const void *const two)) |
|
bk_err | unordered_map_rehash (unordered_map me) |
|
size_t | unordered_map_size (unordered_map me) |
|
bk_bool | unordered_map_is_empty (unordered_map me) |
|
bk_err | unordered_map_put (unordered_map me, void *key, void *value) |
|
bk_bool | unordered_map_get (void *value, unordered_map me, void *key) |
|
bk_bool | unordered_map_contains (unordered_map me, void *key) |
|
bk_bool | unordered_map_remove (unordered_map me, void *key) |
|
bk_err | unordered_map_clear (unordered_map me) |
|
unordered_map | unordered_map_destroy (unordered_map me) |
|
◆ unordered_map
The unordered_map data structure, which is a collection of key-value pairs, hashed by keys, keys are unique
◆ unordered_map_clear()
Clears the key-value pairs from the unordered map.
- Parameters
-
me | the unordered map to clear |
- Returns
- BK_OK if no error
-
-BK_ENOMEM if out of memory
◆ unordered_map_contains()
Determines if the unordered map contains the specified key. The pointer to the key being passed in should point to the key type which this unordered map holds. For example, if this unordered map holds key integers, the key pointer should be a pointer to an integer. Since the key is being copied, the pointer only has to be valid when this function is called.
- Parameters
-
me | the unordered map to check for the key |
key | the key to check |
- Returns
- BK_TRUE if the unordered map contained the key, otherwise BK_FALSE
◆ unordered_map_destroy()
Frees the unordered map memory. Performing further operations after calling this function results in undefined behavior. Freeing NULL is legal, and causes no operation to be performed.
- Parameters
-
me | the unordered map to free from memory |
- Returns
- NULL
◆ unordered_map_get()
Gets the value associated with a key in the unordered map. The pointer to the key being passed in and the value being obtained should point to the key and value types which this unordered map holds. For example, if this unordered map holds integer keys and values, the key and value pointers should be a pointer to an integer. Since the key and value are being copied, the pointer only has to be valid when this function is called.
- Parameters
-
value | the value to copy to |
me | the unordered map to get from |
key | the key to search for |
- Returns
- BK_TRUE if the unordered map contained the key-value pair, otherwise BK_FALSE
◆ unordered_map_init()
unordered_map unordered_map_init |
( |
size_t |
key_size, |
|
|
size_t |
value_size, |
|
|
unsigned long(*)(const void *const key) |
hash, |
|
|
int(*)(const void *const one, const void *const two) |
comparator |
|
) |
| |
◆ unordered_map_is_empty()
Determines whether or not the unordered map is empty.
- Parameters
-
me | the unordered map to check |
- Returns
- BK_TRUE if the unordered map is empty, otherwise BK_FALSE
◆ unordered_map_put()
Adds a key-value pair to the unordered map. If the unordered map already contains the key, the value is updated to the new value. The pointer to the key and value being passed in should point to the key and value type which this unordered map holds. For example, if this unordered map holds integer keys and values, the key and value pointer should be a pointer to an integer. Since the key and value are being copied, the pointer only has to be valid when this function is called.
- Parameters
-
me | the unordered map to add to |
key | the key to add |
value | the value to add |
- Returns
- BK_OK if no error
-
-BK_ENOMEM if out of memory
◆ unordered_map_rehash()
Rehashes all the keys in the unordered map. Used when storing references and changing the keys. This should rarely be used.
- Parameters
-
me | the unordered map to rehash |
- Returns
- BK_OK if no error
-
-BK_ENOMEM if out of memory
◆ unordered_map_remove()
Removes the key-value pair from the unordered map if it contains it. The pointer to the key being passed in should point to the key type which this unordered map holds. For example, if this unordered map holds key integers, the key pointer should be a pointer to an integer. Since the key is being copied, the pointer only has to be valid when this function is called.
- Parameters
-
me | the unordered map to remove a key from |
key | the key to remove |
- Returns
- BK_TRUE if the unordered map contained the key, otherwise BK_FALSE
◆ unordered_map_size()
Gets the size of the unordered map.
- Parameters
-
me | the unordered map to check |
- Returns
- the size of the unordered map