Containers
This library provides various containers. Each container has utility functions to manipulate the data it holds. This is an abstraction as to not have to manually manage and reallocate memory.
|
Macros | |
#define | BKTHOMPS_U_MULTISET_STARTING_BUCKETS 16 |
#define | BKTHOMPS_U_MULTISET_RESIZE_AT 0.75 |
#define | BKTHOMPS_U_MULTISET_RESIZE_RATIO 2 |
Functions | |
unordered_multiset | unordered_multiset_init (const size_t key_size, unsigned long(*hash)(const void *const), int(*comparator)(const void *const, const void *const)) |
bk_err | unordered_multiset_rehash (unordered_multiset me) |
size_t | unordered_multiset_size (unordered_multiset me) |
bk_bool | unordered_multiset_is_empty (unordered_multiset me) |
bk_err | unordered_multiset_put (unordered_multiset me, void *const key) |
size_t | unordered_multiset_count (unordered_multiset me, void *const key) |
bk_bool | unordered_multiset_contains (unordered_multiset me, void *const key) |
bk_bool | unordered_multiset_remove (unordered_multiset me, void *const key) |
bk_bool | unordered_multiset_remove_all (unordered_multiset me, void *const key) |
bk_err | unordered_multiset_clear (unordered_multiset me) |
unordered_multiset | unordered_multiset_destroy (unordered_multiset me) |
#define BKTHOMPS_U_MULTISET_RESIZE_AT 0.75 |
#define BKTHOMPS_U_MULTISET_RESIZE_RATIO 2 |
#define BKTHOMPS_U_MULTISET_STARTING_BUCKETS 16 |
bk_err unordered_multiset_clear | ( | unordered_multiset | me | ) |
Clears the keys from the unordered multi-set.
me | the unordered multi-set to clear |
bk_bool unordered_multiset_contains | ( | unordered_multiset | me, |
void *const | key | ||
) |
Determines if the unordered multi-set contains the specified element. The pointer to the key being passed in should point to the key type which this unordered multi-set holds. For example, if this unordered multi-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.
me | the unordered multi-set to check for the key |
key | the key to check |
size_t unordered_multiset_count | ( | unordered_multiset | me, |
void *const | key | ||
) |
Determines the count of a specific key in the unordered multi-set. The pointer to the key being passed in should point to the key type which this unordered multi-set holds. For example, if this unordered multi-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.
me | the unordered multi-set to check for the count |
key | the element to check |
unordered_multiset unordered_multiset_destroy | ( | unordered_multiset | me | ) |
Frees the unordered multi-set memory. Performing further operations after calling this function results in undefined behavior. Freeing NULL is legal, and causes no operation to be performed.
me | the unordered multi-set to free from memory |
unordered_multiset unordered_multiset_init | ( | const size_t | key_size, |
unsigned long(*)(const void *const) | hash, | ||
int(*)(const void *const, const void *const) | comparator | ||
) |
Initializes an unordered multi-set.
key_size | the size of each key in the unordered multi-set; must be positive |
hash | the hash function which computes the hash from the key; must not be NULL |
comparator | the comparator function which compares two keys; must not be NULL |
bk_bool unordered_multiset_is_empty | ( | unordered_multiset | me | ) |
Determines whether or not the unordered multi-set is empty.
me | the unordered multi-set to check |
bk_err unordered_multiset_put | ( | unordered_multiset | me, |
void *const | key | ||
) |
Adds an element to the unordered multi-set. The pointer to the key being passed in should point to the key type which this unordered multi-set holds. For example, if this multi-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.
me | the unordered multi-set to add to |
key | the element to add |
bk_err unordered_multiset_rehash | ( | unordered_multiset | me | ) |
Rehashes all the keys in the unordered multi-set. Used when storing references and changing the keys. This should rarely be used.
me | the unordered multi-set to rehash |
bk_bool unordered_multiset_remove | ( | unordered_multiset | me, |
void *const | key | ||
) |
Removes a key from the unordered multi-set if it contains it. The pointer to the key being passed in should point to the key type which this unordered multi-set holds. For example, if this unordered multi-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.
me | the unordered multi-set to remove a key from |
key | the key to remove |
bk_bool unordered_multiset_remove_all | ( | unordered_multiset | me, |
void *const | key | ||
) |
Removes all the keys specified by the key from an unordered multi-set if it contains the key. The pointer to the key being passed in should point to the key type which this multi-set holds. For example, if this multi-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.
me | the unordered multi-set to remove a key from |
key | the key to remove |
size_t unordered_multiset_size | ( | unordered_multiset | me | ) |
Gets the size of the unordered multi-set.
me | the unordered multi-set to check |