Go to the source code of this file.
◆ unordered_set
The unordered_set data structure, which is a collection of unique keys, hashed by keys.
◆ unordered_set_clear()
Clears the keys from the unordered set.
- Parameters
-
me | the unordered set to clear |
- Returns
- BK_OK if no error
-
-BK_ENOMEM if out of memory
◆ unordered_set_contains()
Determines if the unordered set contains the specified element. The pointer to the key being passed in should point to the key type which this unordered set holds. For example, if this unordered set 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 set to check for the element |
key | the element to check |
- Returns
- BK_TRUE if the unordered set contained the element, otherwise BK_FALSE
◆ unordered_set_destroy()
Frees the unordered set 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 set to free from memory |
- Returns
- NULL
◆ unordered_set_init()
unordered_set unordered_set_init |
( |
size_t |
key_size, |
|
|
unsigned long(*)(const void *const key) |
hash, |
|
|
int(*)(const void *const one, const void *const two) |
comparator |
|
) |
| |
◆ unordered_set_is_empty()
Determines whether or not the unordered set is empty.
- Parameters
-
me | the unordered set to check |
- Returns
- BK_TRUE if the unordered set is empty, otherwise BK_FALSE
◆ unordered_set_put()
Adds an element to the unordered set if the unordered set does not already contain it. The pointer to the key being passed in should point to the key type which this unordered set holds. For example, if this unordered set 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 set to add to |
key | the element to add |
- Returns
- BK_OK if no error
-
-BK_ENOMEM if out of memory
◆ unordered_set_rehash()
Rehashes all the keys in the unordered set. Used when storing references and changing the keys. This should rarely be used.
- Parameters
-
me | the unordered set to rehash |
- Returns
- BK_OK if no error
-
-BK_ENOMEM if out of memory
◆ unordered_set_remove()
Removes the key from the unordered set if it contains it. The pointer to the key being passed in should point to the key type which this unordered set holds. For example, if this unordered set 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 set to remove a key from |
key | the key to remove |
- Returns
- BK_TRUE if the unordered set contained the key, otherwise BK_FALSE
◆ unordered_set_size()
Gets the size of the unordered set.
- Parameters
-
me | the unordered set to check |
- Returns
- the size of the unordered set