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 | |
set | set_init (const size_t key_size, int(*const comparator)(const void *const, const void *const)) |
size_t | set_size (set me) |
bk_bool | set_is_empty (set me) |
bk_err | set_put (set me, void *const key) |
bk_bool | set_contains (set me, void *const key) |
bk_err | set_remove (set me, void *const key) |
void * | set_first (set me) |
void * | set_last (set me) |
void * | set_lower (set me, void *const key) |
void * | set_higher (set me, void *const key) |
void * | set_floor (set me, void *const key) |
void * | set_ceiling (set me, void *const key) |
void | set_clear (set me) |
set | set_destroy (set me) |
void* set_ceiling | ( | set | 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 set to get the ceiling key from |
key | the key to use for comparison |
void set_clear | ( | set | me | ) |
Clears the keys from the set.
me | the set to clear |
Determines if the set contains the specified key. The pointer to the key being passed in should point to the key type which this set holds. For example, if this 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 set to check for the key |
key | the key to check |
Frees the 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 set to free from memory |
void* set_first | ( | set | me | ) |
Returns the first (lowest) key in this 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 set to get the key from |
void* set_floor | ( | set | 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 set to get the floor key from |
key | the key to use for comparison |
void* set_higher | ( | set | 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 set to get the higher key from |
key | the key to use for comparison |
set set_init | ( | const size_t | key_size, |
int(*)(const void *const, const void *const) | comparator | ||
) |
Initializes a set.
key_size | the size of each element in the set; must be positive |
comparator | the comparator function used for key ordering; must not be NULL |
Determines whether or not the set is empty.
me | the set to check |
void* set_last | ( | set | me | ) |
Returns the last (highest) key in this 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 set to get the key from |
void* set_lower | ( | set | 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 set to get the lower key from |
key | the key to use for comparison |
Adds a key to the set if the set does not already contain it. The pointer to the key being passed in should point to the key type which this set holds. For example, if this 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 set to add to |
key | the key to add |
Removes the key from the set if it contains it. The pointer to the key being passed in should point to the key type which this set holds. For example, if this 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 set to remove an key from |
key | the key to remove |
size_t set_size | ( | set | me | ) |
Gets the size of the set.
me | the set to check |