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.
|
Functions | |
multiset | multiset_init (const size_t key_size, int(*const comparator)(const void *const, const void *const)) |
size_t | multiset_size (multiset me) |
bk_bool | multiset_is_empty (multiset me) |
bk_bool | multiset_put (multiset me, void *const key) |
size_t | multiset_count (multiset me, void *const key) |
bk_bool | multiset_contains (multiset me, void *const key) |
bk_bool | multiset_remove (multiset me, void *const key) |
bk_bool | multiset_remove_all (multiset me, void *const key) |
void * | multiset_first (multiset me) |
void * | multiset_last (multiset me) |
void * | multiset_lower (multiset me, void *const key) |
void * | multiset_higher (multiset me, void *const key) |
void * | multiset_floor (multiset me, void *const key) |
void * | multiset_ceiling (multiset me, void *const key) |
void | multiset_clear (multiset me) |
multiset | multiset_destroy (multiset me) |
void* multiset_ceiling | ( | multiset | me, |
void *const | key | ||
) |
Returns the key which is the ceiling of the comparison key. Meaning that the the lowest key which is higher or equal to the key used for comparison is returned.
me | the multi-set to get the ceiling key from |
key | the key to use for comparison |
void multiset_clear | ( | multiset | me | ) |
Clears the keys from the multiset.
me | the multi-set to clear |
Determines if the multi-set contains the specified 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 multi-set to check for the key |
key | the key to check |
size_t multiset_count | ( | multiset | me, |
void *const | key | ||
) |
Determines the count of a specific key in the multi-set. 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 multi-set to check for the count |
key | the key to check |
Frees the 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 multi-set to free from memory |
void* multiset_first | ( | multiset | me | ) |
Returns the first (lowest) key in this multi-set. The returned key is a pointer to the internally stored key, which should not be modified. Modifying it results in undefined behaviour.
me | the multi-set to get the key from |
void* multiset_floor | ( | multiset | me, |
void *const | key | ||
) |
Returns the key which is the floor of the comparison key. Meaning that the the highest key which is lower or equal to the key used for comparison is returned.
me | the multi-set to get the floor key from |
key | the key to use for comparison |
void* multiset_higher | ( | multiset | me, |
void *const | key | ||
) |
Returns the key which is strictly higher than the comparison key. Meaning that the lowest key which is higher than the key used for comparison is returned.
me | the multi-set to get the higher key from |
key | the key to use for comparison |
multiset multiset_init | ( | const size_t | key_size, |
int(*)(const void *const, const void *const) | comparator | ||
) |
Initializes a multi-set.
key_size | the size of each element in the multi-set; must be positive |
comparator | the comparator function used for key ordering; must not be NULL |
Determines whether or not the multi-set is empty.
me | the multi-set to check |
void* multiset_last | ( | multiset | me | ) |
Returns the last (highest) key in this multi-set. The returned key is a pointer to the internally stored key, which should not be modified. Modifying it results in undefined behaviour.
me | the multi-set to get the key from |
void* multiset_lower | ( | multiset | me, |
void *const | key | ||
) |
Returns the key which is strictly lower than the comparison key. Meaning that the highest key which is lower than the key used for comparison is returned.
me | the multi-set to get the lower key from |
key | the key to use for comparison |
Adds a key to the multi-set. 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 multi-set to add to |
key | the key to add |
Removes a key from the multi-set if it contains it. 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 multi-set to remove a key from |
key | the key to remove |
Removes all the occurrences of a specified key in the multi-set. 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 multi-set to remove a key from |
key | the key to remove |
size_t multiset_size | ( | multiset | me | ) |
Gets the size of the multi-set.
me | the multi-set to check |