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 | |
priority_queue | priority_queue_init (const size_t data_size, int(*comparator)(const void *const, const void *const)) |
size_t | priority_queue_size (priority_queue me) |
bk_bool | priority_queue_is_empty (priority_queue me) |
bk_err | priority_queue_push (priority_queue me, void *const data) |
bk_bool | priority_queue_pop (void *const data, priority_queue me) |
bk_bool | priority_queue_front (void *const data, priority_queue me) |
bk_err | priority_queue_clear (priority_queue me) |
priority_queue | priority_queue_destroy (priority_queue me) |
bk_err priority_queue_clear | ( | priority_queue | me | ) |
Clears the elements from the priority queue.
me | the priority queue to clear |
priority_queue priority_queue_destroy | ( | priority_queue | me | ) |
Frees the priority queue 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 priority queue to free from memory |
bk_bool priority_queue_front | ( | void *const | data, |
priority_queue | me | ||
) |
Gets the highest priority element in the priority queue. The pointer to the data being obtained should point to the data type which this priority queue holds. For example, if this priority queue holds integers, the data pointer should be a pointer to an integer. Since this data is being copied from the array to the data pointer, the pointer only has to be valid when this function is called.
data | the out copy of the highest priority element in the priority queue |
me | the priority queue to copy from |
priority_queue priority_queue_init | ( | const size_t | data_size, |
int(*)(const void *const, const void *const) | comparator | ||
) |
Initializes a priority queue.
data_size | the size of the data in the priority queue; must be positive |
comparator | the priority comparator function; must not be NULL |
bk_bool priority_queue_is_empty | ( | priority_queue | me | ) |
Determines whether or not the priority queue is empty.
me | the priority queue to check |
bk_bool priority_queue_pop | ( | void *const | data, |
priority_queue | me | ||
) |
Removes the highest priority element from the priority queue. The pointer to the data being obtained should point to the data type which this priority queue holds. For example, if this priority queue holds integers, the data pointer should be a pointer to an integer. Since this data is being copied from the array to the data pointer, the pointer only has to be valid when this function is called.
data | the data to have copied from the priority queue |
me | the priority queue to pop the next element from |
bk_err priority_queue_push | ( | priority_queue | me, |
void *const | data | ||
) |
Adds an element to the priority queue. The pointer to the data being passed in should point to the data type which this priority queue holds. For example, if this priority queue holds integers, the data pointer should be a pointer to an integer. Since the data is being copied, the pointer only has to be valid when this function is called.
me | the priority queue to add an element to |
data | the data to add to the queue |
size_t priority_queue_size | ( | priority_queue | me | ) |
Gets the size of the priority queue.
me | the priority queue to check |