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.
|
#include <stdlib.h>
Go to the source code of this file.
Macros | |
#define | BK_OK 0 |
#define | BK_ENOMEM 12 |
#define | BK_EINVAL 22 |
#define | BK_ERANGE 34 |
#define | BK_FALSE 0 |
#define | BK_TRUE (!BK_FALSE) |
#define | BKTHOMPS_CONTAINERS_ARRAY_H |
#define | BKTHOMPS_CONTAINERS_DEQUE_H |
#define | BKTHOMPS_CONTAINERS_FORWARD_LIST_H |
#define | BKTHOMPS_CONTAINERS_LIST_H |
#define | BKTHOMPS_CONTAINERS_MAP_H |
#define | BKTHOMPS_CONTAINERS_MULTIMAP_H |
#define | BKTHOMPS_CONTAINERS_MULTISET_H |
#define | BKTHOMPS_CONTAINERS_PRIORITY_QUEUE_H |
#define | BKTHOMPS_CONTAINERS_QUEUE_H |
#define | BKTHOMPS_CONTAINERS_SET_H |
#define | BKTHOMPS_CONTAINERS_STACK_H |
#define | BKTHOMPS_CONTAINERS_UNORDERED_MAP_H |
#define | BKTHOMPS_CONTAINERS_UNORDERED_MULTIMAP_H |
#define | BKTHOMPS_CONTAINERS_UNORDERED_MULTISET_H |
#define | BKTHOMPS_CONTAINERS_UNORDERED_SET_H |
#define | BKTHOMPS_CONTAINERS_VECTOR_H |
Typedefs | |
typedef int | bk_err |
typedef int | bk_bool |
typedef char * | array |
typedef struct internal_deque * | deque |
typedef struct internal_forward_list * | forward_list |
typedef struct internal_list * | list |
typedef struct internal_map * | map |
typedef struct internal_multimap * | multimap |
typedef struct internal_multiset * | multiset |
typedef struct internal_priority_queue * | priority_queue |
typedef struct internal_deque * | queue |
typedef struct internal_set * | set |
typedef struct internal_deque * | stack |
typedef struct internal_unordered_map * | unordered_map |
typedef struct internal_unordered_multimap * | unordered_multimap |
typedef struct internal_unordered_multiset * | unordered_multiset |
typedef struct internal_unordered_set * | unordered_set |
typedef struct internal_vector * | vector |
#define BK_EINVAL 22 |
#define BK_ENOMEM 12 |
#define BK_ERANGE 34 |
#define BK_FALSE 0 |
#define BK_OK 0 |
#define BK_TRUE (!BK_FALSE) |
#define BKTHOMPS_CONTAINERS_ARRAY_H |
#define BKTHOMPS_CONTAINERS_DEQUE_H |
#define BKTHOMPS_CONTAINERS_FORWARD_LIST_H |
#define BKTHOMPS_CONTAINERS_LIST_H |
#define BKTHOMPS_CONTAINERS_MAP_H |
#define BKTHOMPS_CONTAINERS_MULTIMAP_H |
#define BKTHOMPS_CONTAINERS_MULTISET_H |
#define BKTHOMPS_CONTAINERS_PRIORITY_QUEUE_H |
#define BKTHOMPS_CONTAINERS_QUEUE_H |
#define BKTHOMPS_CONTAINERS_SET_H |
#define BKTHOMPS_CONTAINERS_STACK_H |
#define BKTHOMPS_CONTAINERS_UNORDERED_MAP_H |
#define BKTHOMPS_CONTAINERS_UNORDERED_MULTIMAP_H |
#define BKTHOMPS_CONTAINERS_UNORDERED_MULTISET_H |
#define BKTHOMPS_CONTAINERS_UNORDERED_SET_H |
#define BKTHOMPS_CONTAINERS_VECTOR_H |
typedef char* array |
The array data structure, which is a static contiguous array.
typedef int bk_bool |
typedef int bk_err |
typedef struct internal_deque* deque |
The deque data structure, which is a doubly-ended queue.
typedef struct internal_forward_list* forward_list |
The forward_list data structure, which is a singly-linked list.
typedef struct internal_list* list |
The list data structure, which is a doubly-linked list.
typedef struct internal_map* map |
The map data structure, which is a collection of key-value pairs, sorted by keys, keys are unique.
typedef struct internal_multimap* multimap |
The multimap data structure, which is a collection of key-value pairs, sorted by keys.
typedef struct internal_multiset* multiset |
The multiset data structure, which is a collection of key-value pairs, sorted by keys, keys are unique
typedef struct internal_priority_queue* priority_queue |
The priority_queue data structure, which adapts a container to provide a priority queue. Adapts the vector container.
typedef struct internal_deque* queue |
The queue data structure, which adapts a container to provide a queue (first-in first-out). Adapts the deque container.
typedef struct internal_set* set |
The set data structure, which is a collection of unique keys, sorted by keys.
typedef struct internal_deque* stack |
The stack data structure, which adapts a container to provide a stack (last-in first-out). Adapts the deque container.
typedef struct internal_unordered_map* unordered_map |
The unordered_map data structure, which is a collection of key-value pairs, hashed by keys, keys are unique
typedef struct internal_unordered_multimap* unordered_multimap |
The unordered_multimap data structure, which is a collection of key-value pairs, hashed by keys.
typedef struct internal_unordered_multiset* unordered_multiset |
The unordered_multiset data structure, which is a collection of keys, hashed by keys.
typedef struct internal_unordered_set* unordered_set |
The unordered_set data structure, which is a collection of unique keys, hashed by keys.
typedef struct internal_vector* vector |
The vector data structure, which is a dynamic contiguous array.
Copies elements from a raw array to the array. The size specifies the number of elements to copy starting from the start of the raw array, which must be less than or equal to the size of both the raw array and of the array. The elements are copied to the array starting at the start of the array.
me | the array to add data to |
arr | the raw array to copy data from |
size | the number of elements to copy |
void array_copy_to_array | ( | void *const | arr, |
array | me | ||
) |
Copies the array to a raw array. Since it is a copy, the raw array may be modified without causing side effects to the array data structure. Memory is not allocated, thus the raw array being used for the copy must be allocated before this function is called. The size of the array should be queried prior to calling this function, which also serves as the size of the newly-copied raw array.
arr | the initialized raw array to copy the array to |
me | the array to copy to the raw array |
Frees the array 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 array to free from memory |
Copies the element at an index of the array to data. The pointer to the data being obtained should point to the data type which this array holds. For example, if this array 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 copy to |
me | the array to copy from |
index | the index to copy from in the array |
void* array_get_data | ( | array | me | ) |
Gets the storage element of the array structure. The storage element is contiguous in memory. The data pointer should be assigned to the correct array type. For example, if the array holds integers, the data pointer should be assigned to a raw integer array. The size of the array should be obtained prior to calling this function, which also serves as the size of the queried raw array. This pointer is not a copy, thus any modification to the data will cause the array structure data to be modified. Operations using the array functions may invalidate this pointer. The array owns this memory, thus it should not be freed. If the array size if 0, this should not be used.
me | the array to get the storage element from |
array array_init | ( | const size_t | element_count, |
const size_t | data_size | ||
) |
Initializes an array.
element_count | the number of elements in the array; must not be negative |
data_size | the size of each element in the array; must be positive |
Sets the data for a specified element in the array. The pointer to the data being passed in should point to the data type which this array holds. For example, if this array 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 array to set data for |
index | the location to set data at in the array |
data | the data to set at the location in the array |
size_t array_size | ( | array | me | ) |
Gets the size of the array.
me | the array to check |
Copies elements from an array to the deque. The size specifies the number of elements to copy, starting from the beginning of the array. The size must be less than or equal to the size of the array.
me | the deque to add data to |
arr | the array to copy data from |
size | the number of elements to copy |
Clears the deque and sets it to the original state from initialization.
me | the deque to clear |
void deque_copy_to_array | ( | void *const | arr, |
deque | me | ||
) |
Copies the deque to an array. Since it is a copy, the array may be modified without causing side effects to the deque data structure. Memory is not allocated, thus the array being used for the copy must be allocated before this function is called. The size of the deque should be queried prior to calling this function, which also serves as the size of the newly-copied array.
arr | the initialized array to copy the deque to |
me | the deque to copy to the array |
Destroys the deque. Performing further operations after calling this function results in undefined behavior. Freeing NULL is legal, and causes no operation to be performed.
me | the deque to destroy |
Gets the value of the deque at the specified index. The pointer to the data being obtained should point to the data type which this deque holds. For example, if this deque 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 set |
me | the deque to set the value of |
index | the index to set at |
Gets the first value of the deque. The pointer to the data being obtained should point to the data type which this deque holds. For example, if this deque 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 set |
me | the deque to set the value of |
Gets the last value of the deque. The pointer to the data being obtained should point to the data type which this deque holds. For example, if this deque 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 set |
me | the deque to set the value of |
deque deque_init | ( | const size_t | data_size | ) |
Initializes a deque.
data_size | the size of each element in the deque; must be positive |
Determines if the deque is empty. It is empty if it has no elements.
me | the deque to check if empty |
Removes the back element from the deque and copies it to a data value. The pointer to the data being obtained should point to the data type which this deque holds. For example, if this deque 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 value to copy to |
me | the deque to remove from |
Removes the front element from the deque and copies it to a data value. The pointer to the data being obtained should point to the data type which this deque holds. For example, if this deque 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 value to copy to |
me | the deque to remove from |
Adds an element to the back of the deque. The pointer to the data being passed in should point to the data type which this deque holds. For example, if this deque 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 deque to add an element to |
data | the element to add |
Adds an element to the front of the deque. The pointer to the data being passed in should point to the data type which this deque holds. For example, if this deque 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 deque to add an element to |
data | the element to add |
Sets the value of the deque at the specified index. The pointer to the data being passed in should point to the data type which this deque holds. For example, if this deque 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 deque to set the value of |
index | the index to set at |
data | the data to set |
Sets the first value of the deque. The pointer to the data being passed in should point to the data type which this deque holds. For example, if this deque 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 deque to set the value of |
data | the data to set |
Sets the last value of the deque. The pointer to the data being passed in should point to the data type which this deque holds. For example, if this deque 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 deque to set the value of |
data | the data to set |
size_t deque_size | ( | deque | me | ) |
Determines the size of the deque. The size is the number of data spaces being used. The size starts at zero, and every time an element is added, it increases by one.
me | the deque to check the size of |
Trims the deque so that it does not use memory which does not need to be used.
me | the deque to trim |
bk_err forward_list_add_all | ( | forward_list | me, |
void *const | arr, | ||
const size_t | size | ||
) |
Copies elements from an array to the singly-linked list. The size specifies the number of elements to copy, starting from the beginning of the array. The size must be less than or equal to the size of the array.
me | the singly-linked list to add data to |
arr | the array to copy data from |
size | the number of elements to copy |
bk_err forward_list_add_at | ( | forward_list | me, |
const size_t | index, | ||
void *const | data | ||
) |
Adds data at a specified index in the singly-linked list. The pointer to the data being passed in should point to the data type which this singly-linked list holds. For example, if this singly-linked list 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 singly-linked list to add data to |
index | the index to add the data at |
data | the data to add to the singly-linked list |
bk_err forward_list_add_first | ( | forward_list | me, |
void *const | data | ||
) |
Adds data at the first index in the singly-linked list. The pointer to the data being passed in should point to the data type which this singly-linked list holds. For example, if this singly-linked list 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 singly-linked list to add data to |
data | the data to add to the singly-linked list |
bk_err forward_list_add_last | ( | forward_list | me, |
void *const | data | ||
) |
Adds data at the last index in the singly-linked list. The pointer to the data being passed in should point to the data type which this singly-linked list holds. For example, if this singly-linked list 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 singly-linked list to add data to |
data | the data to add to the singly-linked list |
void forward_list_clear | ( | forward_list | me | ) |
Clears all elements from the singly-linked list.
me | the singly-linked list to clear |
void forward_list_copy_to_array | ( | void *const | arr, |
forward_list | me | ||
) |
Copies the nodes of the singly-linked list to an array. Since it is a copy, the array may be modified without causing side effects to the singly-linked list data structure. Memory is not allocated, thus the array being used for the copy must be allocated before this function is called. The size of the singly-linked list should be queried prior to calling this function, which also serves as the size of the newly-copied array.
arr | the initialized array to copy the singly-linked list to |
me | the singly-linked list to copy to the array |
forward_list forward_list_destroy | ( | forward_list | me | ) |
Destroys the singly-linked list. Performing further operations after calling this function results in undefined behavior. Freeing NULL is legal, and causes no operation to be performed.
me | the singly-linked list to destroy |
bk_err forward_list_get_at | ( | void *const | data, |
forward_list | me, | ||
const size_t | index | ||
) |
Gets the data at the specified index in the singly-linked list. The pointer to the data being obtained should point to the data type which this singly- linked list holds. For example, if this singly-linked list 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 get |
me | the singly-linked list to get data from |
index | the index to get data from |
bk_err forward_list_get_first | ( | void *const | data, |
forward_list | me | ||
) |
Gets the data at the first index in the singly-linked list. The pointer to the data being obtained should point to the data type which this singly- linked list holds. For example, if this singly-linked list 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 get |
me | the singly-linked list to get data from |
bk_err forward_list_get_last | ( | void *const | data, |
forward_list | me | ||
) |
Gets the data at the last index in the singly-linked list. The pointer to the data being obtained should point to the data type which this singly- linked list holds. For example, if this singly-linked list 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 get |
me | the singly-linked list to get data from |
forward_list forward_list_init | ( | const size_t | data_size | ) |
Initializes a singly-linked list.
data_size | the size of data to store; must be positive |
bk_bool forward_list_is_empty | ( | forward_list | me | ) |
Determines if the singly-linked list is empty.
me | the singly-linked list to check |
bk_err forward_list_remove_at | ( | forward_list | me, |
const size_t | index | ||
) |
Removes data from the singly-linked list at the specified index.
me | the singly-linked list to remove data from |
index | the index to remove from |
bk_err forward_list_remove_first | ( | forward_list | me | ) |
Removes the first piece of data from the singly-linked list.
me | the singly-linked list to remove data from |
bk_err forward_list_remove_last | ( | forward_list | me | ) |
Removes the last piece of data from the singly-linked list.
me | the singly-linked list to remove data from |
bk_err forward_list_set_at | ( | forward_list | me, |
const size_t | index, | ||
void *const | data | ||
) |
Sets the data at the specified index in the singly-linked list. The pointer to the data being passed in should point to the data type which this singly- linked list holds. For example, if this singly-linked list 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 singly-linked list to set data for |
index | the index to set data in the singly-linked list |
data | the data to set in the singly-linked list |
bk_err forward_list_set_first | ( | forward_list | me, |
void *const | data | ||
) |
Sets the data at the first index in the singly-linked list. The pointer to the data being passed in should point to the data type which this singly- linked list holds. For example, if this singly-linked list 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 singly-linked list to set data for |
data | the data to set in the singly-linked list |
bk_err forward_list_set_last | ( | forward_list | me, |
void *const | data | ||
) |
Sets the data at the last index in the singly-linked list. The pointer to the data being passed in should point to the data type which this singly- linked list holds. For example, if this singly-linked list 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 singly-linked list to set data for |
data | the data to set in the singly-linked list |
size_t forward_list_size | ( | forward_list | me | ) |
Gets the number of elements in the singly-linked list.
me | the singly-linked list to check |
Copies elements from an array to the doubly-linked list. The size specifies the number of elements to copy, starting from the beginning of the array. The size must be less than or equal to the size of the array.
me | the doubly-linked list to add data to |
arr | the array to copy data from |
size | the number of elements to copy |
Adds data at a specified index in the doubly-linked list. The pointer to the data being passed in should point to the data type which this doubly-linked list holds. For example, if this doubly-linked list 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 doubly-linked list to add data to |
index | the index to add the data at |
data | the data to add to the doubly-linked list |
Adds data at the first index in the doubly-linked list. The pointer to the data being passed in should point to the data type which this doubly-linked list holds. For example, if this doubly-linked list 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 doubly-linked list to add data to |
data | the data to add to the doubly-linked list |
Adds data at the last index in the doubly-linked list. The pointer to the data being passed in should point to the data type which this doubly-linked list holds. For example, if this doubly-linked list 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 doubly-linked list to add data to |
data | the data to add to the doubly-linked list |
void list_clear | ( | list | me | ) |
Clears all elements from the doubly-linked list.
me | the doubly-linked list to clear |
void list_copy_to_array | ( | void *const | arr, |
list | me | ||
) |
Copies the nodes of the doubly-linked list to an array. Since it is a copy, the array may be modified without causing side effects to the doubly-linked list data structure. Memory is not allocated, thus the array being used for the copy must be allocated before this function is called. The size of the doubly-linked list should be queried prior to calling this function, which also serves as the size of the newly-copied array.
arr | the initialized array to copy the doubly-linked list to |
me | the doubly-linked list to copy to the array |
Destroys the doubly-linked list. Performing further operations after calling this function results in undefined behavior. Freeing NULL is legal, and causes no operation to be performed.
me | the doubly-linked list to destroy |
Gets the data at the specified index in the doubly-linked list. The pointer to the data being obtained should point to the data type which this doubly- linked list holds. For example, if this doubly-linked list 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 get |
me | the doubly-linked list to get data from |
index | the index to get data from |
Gets the data at the first index in the doubly-linked list. The pointer to the data being obtained should point to the data type which this doubly- linked list holds. For example, if this doubly-linked list 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 get |
me | the doubly-linked list to get data from |
Gets the data at the last index in the doubly-linked list. The pointer to the data being obtained should point to the data type which this doubly- linked list holds. For example, if this doubly-linked list 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 get |
me | the doubly-linked list to get data from |
list list_init | ( | const size_t | data_size | ) |
Initializes a doubly-linked list.
data_size | the size of data to store; must be positive |
Determines if the doubly-linked list is empty.
me | the doubly-linked list to check |
Removes data from the doubly-linked list at the specified index.
me | the doubly-linked list to remove data from |
index | the index to remove from |
Removes the first piece of data from the doubly-linked list.
me | the doubly-linked list to remove data from |
Removes the last piece of data from the doubly-linked list.
me | the doubly-linked list to remove data from |
Sets the data at the specified index in the doubly-linked list. The pointer to the data being passed in should point to the data type which this doubly- linked list holds. For example, if this doubly-linked list 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 doubly-linked list to set data for |
index | the index to set data in the doubly-linked list |
data | the data to set in the doubly-linked list |
Sets the data at the first index in the doubly-linked list. The pointer to the data being passed in should point to the data type which this doubly- linked list holds. For example, if this doubly-linked list 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 doubly-linked list to set data for |
data | the data to set in the doubly-linked list |
Sets the data at the last index in the doubly-linked list. The pointer to the data being passed in should point to the data type which this doubly- linked list holds. For example, if this doubly-linked list 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 doubly-linked list to set data for |
data | the data to set in the doubly-linked list |
size_t list_size | ( | list | me | ) |
Gets the number of elements in the doubly-linked list.
me | the doubly-linked list to check |
void* map_ceiling | ( | map | 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 map to get the ceiling key from |
key | the key to use for comparison |
void map_clear | ( | map | me | ) |
Clears the key-value pairs from the map.
me | the map to clear |
Determines if the map contains the specified key. The pointer to the key being passed in should point to the key type which this map holds. For example, if this map 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 map to check for the element |
key | the key to check |
Frees the map 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 map to free from memory |
void* map_first | ( | map | me | ) |
Returns the first (lowest) key in this map. The returned key is a pointer to the internally stored key, which should not be modified. Modifying it results in undefined behaviour.
me | the map to get the key from |
void* map_floor | ( | map | 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 map to get the floor key from |
key | the key to use for comparison |
Gets the value associated with a key in the map. The pointer to the key being passed in and the value being obtained should point to the key and value types which this map holds. For example, if this map holds integer keys and values, the key and value pointers should be a pointer to an integer. Since the key and value are being copied, the pointer only has to be valid when this function is called.
value | the value to copy to |
me | the map to get from |
key | the key to search for |
void* map_higher | ( | map | 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 map to get the higher key from |
key | the key to use for comparison |
map map_init | ( | size_t | key_size, |
size_t | value_size, | ||
int(*)(const void *const one, const void *const two) | comparator | ||
) |
Determines whether or not the map is empty.
me | the map to check |
void* map_last | ( | map | me | ) |
Returns the last (highest) key in this map. The returned key is a pointer to the internally stored key, which should not be modified. Modifying it results in undefined behaviour.
me | the map to get the key from |
void* map_lower | ( | map | 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 map to get the lower key from |
key | the key to use for comparison |
Adds a key-value pair to the map. If the map already contains the key, the value is updated to the new value. The pointer to the key and value being passed in should point to the key and value type which this map holds. For example, if this map holds integer keys and values, the key and value pointer should be a pointer to an integer. Since the key and value are being copied, the pointer only has to be valid when this function is called.
me | the map to add to |
key | the key to add |
value | the value to add |
Removes the key-value pair from the map if it contains it. The pointer to the key being passed in should point to the key type which this map holds. For example, if this map 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 map to remove an element from |
key | the key to remove |
size_t map_size | ( | map | me | ) |
Gets the size of the map.
me | the map to check |
void* multimap_ceiling | ( | multimap | 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-map to get the ceiling key from |
key | the key to use for comparison |
void multimap_clear | ( | multimap | me | ) |
Clears the key-value pairs from the multi-map.
me | the multi-map to clear |
Determines if the multi-map contains the specified key. The pointer to the key being passed in should point to the key type which this multi-map holds. For example, if this multi-map 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-map to check for the key |
key | the key to check |
size_t multimap_count | ( | multimap | me, |
void *const | key | ||
) |
Determines the number of times the key appears in the multi-map. The pointer to the key being passed in should point to the key type which this multi-map holds. For example, if this multi-map 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-map to check for the key |
key | the key to check |
Frees the multi-map 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-map to free from memory |
void* multimap_first | ( | multimap | me | ) |
Returns the first (lowest) key in this multi-map. 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-map to get the key from |
void* multimap_floor | ( | multimap | 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-map to get the floor key from |
key | the key to use for comparison |
Iterates over the values for the specified key. Must be called after starting the iterator. The multi-map must not be mutated between start and iterations. The pointer to the value being obtained should point to the value type which this multi-map holds. For example, if this multi-map holds value integers, the value pointer should be a pointer to an integer. Since the value is being copied, the pointer only has to be valid when this function is called.
value | the value to be copied to from iteration |
me | the multi-map to iterate over |
void multimap_get_start | ( | multimap | me, |
void *const | key | ||
) |
Creates the iterator for the specified key. To iterate over the values, keep getting the next value. Between starting and iterations, the multi-map must not be mutated. The pointer to the key being passed in should point to the key type which this multi-map holds. For example, if this multi-map 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-map to start the iterator for |
key | the key to start the iterator for |
void* multimap_higher | ( | multimap | 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-map to get the higher key from |
key | the key to use for comparison |
multimap multimap_init | ( | size_t | key_size, |
size_t | value_size, | ||
int(*)(const void *const one, const void *const two) | key_comparator, | ||
int(*)(const void *const one, const void *const two) | value_comparator | ||
) |
Determines whether or not the multi-map is empty.
me | the multi-map to check |
void* multimap_last | ( | multimap | me | ) |
Returns the last (highest) key in this multi-map. 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-map to get the key from |
void* multimap_lower | ( | multimap | 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-map to get the lower key from |
key | the key to use for comparison |
Adds a key-value pair to the multi-map. If the multi-map already contains the key, the value is updated to the new value. The pointer to the key and value being passed in should point to the key and value type which this multi-map holds. For example, if this multi-map holds integer keys and values, the key and value pointer should be a pointer to an integer. Since the key and value are being copied, the pointer only has to be valid when this function is called.
me | the multi-map to add to |
key | the key to add |
value | the value to add |
Removes the key-value pair from the multi-map if it contains it. The pointer to the key and value being passed in should point to the key and value type which this multi-map holds. For example, if this multi-map holds integer keys and values, the key and value pointer should be a pointer to an integer. Since the key and value are being copied, the pointer only has to be valid when this function is called.
me | the multi-map to remove a key from |
key | the key to remove |
value | the value to remove |
Removes all the key-value pairs from the multi-map specified by the key. The pointer to the key being passed in should point to the key type which this multi-map holds. For example, if this multi-map 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-map to remove a key-value pair from |
key | the key to remove |
size_t multimap_size | ( | multimap | me | ) |
Gets the size of the multi-map.
me | the multi-map to check |
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 | ( | size_t | key_size, |
int(*)(const void *const one, const void *const two) | comparator | ||
) |
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 |
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 | ( | size_t | data_size, |
int(*)(const void *const one, const void *const two) | comparator | ||
) |
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 |
Gets the back element of the queue. The pointer to the data being obtained should point to the data type which this queue holds. For example, if this 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 copy of the back element of the queue |
me | the queue to copy from |
Clears the queue and sets it to the original state from initialization.
me | the queue to clear |
void queue_copy_to_array | ( | void *const | arr, |
queue | me | ||
) |
Copies the queue to an array. Since it is a copy, the array may be modified without causing side effects to the queue data structure. Memory is not allocated, thus the array being used for the copy must be allocated before this function is called.
arr | the initialized array to copy the queue to |
me | the queue to copy to the array |
Destroys the queue. Performing further operations after calling this function results in undefined behavior. Freeing NULL is legal, and causes no operation to be performed.
me | the queue to destroy |
Gets the front element of the queue. The pointer to the data being obtained should point to the data type which this queue holds. For example, if this 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 copy of the front element of the queue |
me | the queue to copy from |
queue queue_init | ( | const size_t | data_size | ) |
Initializes a queue.
data_size | the size of each element; must be positive |
Determines if the queue is empty. The queue is empty if it contains no elements.
me | the queue to check if empty |
Removes the next element in the queue and copies the data. The pointer to the data being obtained should point to the data type which this queue holds. For example, if this 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 queue |
me | the queue to pop the next element from |
Adds an element to the queue. The pointer to the data being passed in should point to the data type which this queue holds. For example, if this 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 queue to add an element to |
data | the data to add to the queue |
size_t queue_size | ( | queue | me | ) |
Determines the size of the queue.
me | the queue to get size of |
Frees the unused memory in the queue.
me | the queue to trim |
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 | ( | size_t | key_size, |
int(*)(const void *const one, const void *const two) | comparator | ||
) |
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 |
Clears the stack and sets it to the state from original initialization.
me | the stack to clear |
void stack_copy_to_array | ( | void *const | arr, |
stack | me | ||
) |
Copies the stack to an array. Since it is a copy, the array may be modified without causing side effects to the stack data structure. Memory is not allocated, thus the array being used for the copy must be allocated before this function is called.
arr | the initialized array to copy the stack to |
me | the stack to copy to the array |
Frees the stack 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 stack to destroy |
stack stack_init | ( | const size_t | data_size | ) |
Initializes a stack.
data_size | the size of each data element in the stack; must be positive |
Determines if the stack is empty, meaning it contains no elements.
me | the stack to check if empty |
Removes the top element of the stack, and copies the data which is being removed. The pointer to the data being obtained should point to the data type which this stack holds. For example, if this stack 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 copy of the element being removed |
me | the stack to remove the top element from |
Adds an element to the top of the stack. The pointer to the data being passed in should point to the data type which this stack holds. For example, if this stack 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 stack to add an element to |
data | the data to add to the stack |
size_t stack_size | ( | stack | me | ) |
Determines the size of the stack.
me | the stack to check size of |
Copies the top element of the stack. The pointer to the data being obtained should point to the data type which this stack holds. For example, if this stack 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 copy of the top element of the stack |
me | the stack to copy from |
Frees unused memory from the stack.
me | the stack to trim |
bk_err unordered_map_clear | ( | unordered_map | me | ) |
Clears the key-value pairs from the unordered map.
me | the unordered map to clear |
bk_bool unordered_map_contains | ( | unordered_map | me, |
void *const | key | ||
) |
Determines if the unordered map contains the specified key. The pointer to the key being passed in should point to the key type which this unordered map holds. For example, if this unordered map 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 map to check for the key |
key | the key to check |
unordered_map unordered_map_destroy | ( | unordered_map | me | ) |
Frees the unordered map 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 map to free from memory |
bk_bool unordered_map_get | ( | void *const | value, |
unordered_map | me, | ||
void *const | key | ||
) |
Gets the value associated with a key in the unordered map. The pointer to the key being passed in and the value being obtained should point to the key and value types which this unordered map holds. For example, if this unordered map holds integer keys and values, the key and value pointers should be a pointer to an integer. Since the key and value are being copied, the pointer only has to be valid when this function is called.
value | the value to copy to |
me | the unordered map to get from |
key | the key to search for |
unordered_map unordered_map_init | ( | size_t | key_size, |
size_t | value_size, | ||
unsigned long(*)(const void *const key) | hash, | ||
int(*)(const void *const one, const void *const two) | comparator | ||
) |
bk_bool unordered_map_is_empty | ( | unordered_map | me | ) |
Determines whether or not the unordered map is empty.
me | the unordered map to check |
bk_err unordered_map_put | ( | unordered_map | me, |
void *const | key, | ||
void *const | value | ||
) |
Adds a key-value pair to the unordered map. If the unordered map already contains the key, the value is updated to the new value. The pointer to the key and value being passed in should point to the key and value type which this unordered map holds. For example, if this unordered map holds integer keys and values, the key and value pointer should be a pointer to an integer. Since the key and value are being copied, the pointer only has to be valid when this function is called.
me | the unordered map to add to |
key | the key to add |
value | the value to add |
bk_err unordered_map_rehash | ( | unordered_map | me | ) |
Rehashes all the keys in the unordered map. Used when storing references and changing the keys. This should rarely be used.
me | the unordered map to rehash |
bk_bool unordered_map_remove | ( | unordered_map | me, |
void *const | key | ||
) |
Removes the key-value pair from the unordered map if it contains it. The pointer to the key being passed in should point to the key type which this unordered map holds. For example, if this unordered map 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 map to remove a key from |
key | the key to remove |
size_t unordered_map_size | ( | unordered_map | me | ) |
Gets the size of the unordered map.
me | the unordered map to check |
bk_err unordered_multimap_clear | ( | unordered_multimap | me | ) |
Clears the key-value pairs from the unordered multi-map.
me | the unordered multi-map to clear |
bk_bool unordered_multimap_contains | ( | unordered_multimap | me, |
void *const | key | ||
) |
Determines if the unordered multi-map contains the specified key. The pointer to the key being passed in should point to the key type which this unordered multi-map holds. For example, if this unordered multi-map 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-map to check for the key |
key | the key to check |
size_t unordered_multimap_count | ( | unordered_multimap | me, |
void *const | key | ||
) |
Determines the number of times the key appears in the unordered multi-map. The pointer to the key being passed in should point to the key type which this unordered multi-map holds. For example, if this unordered multi-map 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-map to check for the key |
key | the key to check |
unordered_multimap unordered_multimap_destroy | ( | unordered_multimap | me | ) |
Frees the unordered multi-map 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-map to free from memory |
bk_bool unordered_multimap_get_next | ( | void *const | value, |
unordered_multimap | me | ||
) |
Iterates over the values for the specified key. Must be called after starting the iterator. The unordered multi-map must not be mutated between start and iterations. The pointer to the value being obtained should point to the value type which this unordered multi-map holds. For example, if this unordered multi-map holds value integers, the value pointer should be a pointer to an integer. Since the value is being copied, the pointer only has to be valid when this function is called.
value | the value to be copied to from iteration |
me | the unordered multi-map to iterate over |
void unordered_multimap_get_start | ( | unordered_multimap | me, |
void *const | key | ||
) |
Creates the iterator for the specified key. To iterate over the values, keep getting the next value. Between starting and iterations, the unordered multi-map must not be mutated. The pointer to the key being passed in should point to the key type which this unordered multi-map holds. For example, if this unordered multi-map 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-map to start the iterator for |
key | the key to start the iterator for |
unordered_multimap unordered_multimap_init | ( | size_t | key_size, |
size_t | value_size, | ||
unsigned long(*)(const void *const key) | hash, | ||
int(*)(const void *const one, const void *const two) | key_comparator, | ||
int(*)(const void *const one, const void *const two) | value_comparator | ||
) |
bk_bool unordered_multimap_is_empty | ( | unordered_multimap | me | ) |
Determines whether or not the unordered multi-map is empty.
me | the unordered multi-map to check |
bk_err unordered_multimap_put | ( | unordered_multimap | me, |
void *const | key, | ||
void *const | value | ||
) |
Adds a key-value pair to the unordered multi-map. The pointer to the key and value being passed in should point to the key and value type which this unordered multi-map holds. For example, if this unordered multi-map holds integer keys and values, the key and value pointer should be a pointer to an integer. Since the key and value are being copied, the pointer only has to be valid when this function is called.
me | the unordered multi-map to add to |
key | the key to add |
value | the value to add |
bk_err unordered_multimap_rehash | ( | unordered_multimap | me | ) |
Rehashes all the keys in the unordered multi-map. Used when storing references and changing the keys. This should rarely be used.
me | the unordered multi-map to rehash |
bk_bool unordered_multimap_remove | ( | unordered_multimap | me, |
void *const | key, | ||
void *const | value | ||
) |
Removes the key-value pair from the unordered multi-map if it contains it. The pointer to the key and value being passed in should point to the key and value type which this unordered multi-map holds. For example, if this unordered multi-map holds integer keys and values, the key and value pointer should be a pointer to an integer. Since the key and value are being copied, the pointer only has to be valid when this function is called.
me | the unordered multi-map to remove a key from |
key | the key to remove |
value | the value to remove |
bk_bool unordered_multimap_remove_all | ( | unordered_multimap | me, |
void *const | key | ||
) |
Removes all the key-value pairs from the unordered multi-map specified by the key. The pointer to the key being passed in should point to the key type which this unordered multi-map holds. For example, if this unordered multi-map 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-map to remove a key-value pair from |
key | the key to remove |
size_t unordered_multimap_size | ( | unordered_multimap | me | ) |
Gets the size of the unordered multi-map.
me | the unordered multi-map to check |
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 | ( | size_t | key_size, |
unsigned long(*)(const void *const key) | hash, | ||
int(*)(const void *const one, const void *const two) | comparator | ||
) |
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 |
bk_err unordered_set_clear | ( | unordered_set | me | ) |
Clears the keys from the unordered set.
me | the unordered set to clear |
bk_bool unordered_set_contains | ( | unordered_set | me, |
void *const | key | ||
) |
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.
me | the unordered set to check for the element |
key | the element to check |
unordered_set unordered_set_destroy | ( | unordered_set | me | ) |
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.
me | the unordered set to free from memory |
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 | ||
) |
bk_bool unordered_set_is_empty | ( | unordered_set | me | ) |
Determines whether or not the unordered set is empty.
me | the unordered set to check |
bk_err unordered_set_put | ( | unordered_set | me, |
void *const | key | ||
) |
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.
me | the unordered set to add to |
key | the element to add |
bk_err unordered_set_rehash | ( | unordered_set | me | ) |
Rehashes all the keys in the unordered set. Used when storing references and changing the keys. This should rarely be used.
me | the unordered set to rehash |
bk_bool unordered_set_remove | ( | unordered_set | me, |
void *const | key | ||
) |
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.
me | the unordered set to remove a key from |
key | the key to remove |
size_t unordered_set_size | ( | unordered_set | me | ) |
Gets the size of the unordered set.
me | the unordered set to check |
Copies elements from an array to the vector. The size specifies the number of elements to copy, starting from the beginning of the array. The size must be less than or equal to the size of the array.
me | the vector to add data to |
arr | the array to copy data from |
size | the number of elements to copy |
Adds an element to the location specified. The pointer to the data being passed in should point to the data type which this vector holds. For example, if this vector 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 vector to add to |
index | the location in the vector to add the data to |
data | the data to add to the vector |
Adds an element to the start of the vector. The pointer to the data being passed in should point to the data type which this vector holds. For example, if this vector 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 vector to add to |
data | the data to add to the vector |
Adds an element to the end of the vector.
me | the vector to add to |
data | the data to add to the vector |
size_t vector_capacity | ( | vector | me | ) |
Gets the capacity that the internal storage of the vector is using.
me | the vector to check |
Clears the elements from the vector.
me | the vector to clear |
void vector_copy_to_array | ( | void *const | arr, |
vector | me | ||
) |
Copies the vector to an array. Since it is a copy, the array may be modified without causing side effects to the vector data structure. Memory is not allocated, thus the array being used for the copy must be allocated before this function is called. The size of the vector should be queried prior to calling this function, which also serves as the size of the newly-copied array.
arr | the initialized array to copy the vector to |
me | the vector to copy to the array |
Frees the vector 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 vector to free from memory |
Copies the element at index of the vector to data. The pointer to the data being obtained should point to the data type which this vector holds. For example, if this vector 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 copy to |
me | the vector to copy from |
index | the index to copy from in the vector |
void* vector_get_data | ( | vector | me | ) |
Gets the storage element of the vector structure. The storage element is contiguous in memory. The data pointer should be assigned to the correct array type. For example, if the vector holds integers, the data pointer should be assigned to an integer array. The size of the vector should be obtained prior to calling this function, which also serves as the size of the queried array. This pointer is not a copy, thus any modification to the data will cause the vector structure data to be modified. Operations using the vector functions may invalidate this pointer. The vector owns this memory, thus it should not be freed. This should not be used if the vector is empty.
me | the vector to get the storage element from |
Copies the first element of the vector to data. The pointer to the data being obtained should point to the data type which this vector holds. For example, if this vector 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 copy to |
me | the vector to copy from |
Copies the last element of the vector to data. The pointer to the data being obtained should point to the data type which this vector holds. For example, if this vector 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 copy to |
me | the vector to copy from |
vector vector_init | ( | const size_t | data_size | ) |
Initializes a vector.
data_size | the size of each element in the vector; must be positive |
Determines whether or not the vector is empty.
me | the vector to check |
Removes element based on its index.
me | the vector to remove from |
index | the location in the vector to remove the data from |
Removes the first element from the vector.
me | the vector to remove from |
Removes the last element from the vector.
me | the vector to remove from |
Reserves space specified. If more space than specified is already reserved, then the previous space will be kept.
me | the vector to reserve space for |
size | the space to reserve |
Sets the data for a specified element in the vector. The pointer to the data being passed in should point to the data type which this vector holds. For example, if this vector 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 vector to set data for |
index | the location to set data at in the vector |
data | the data to set at the location in the vector |
Sets the data for the first element in the vector. The pointer to the data being passed in should point to the data type which this vector holds. For example, if this vector 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 vector to set data for |
data | the data to set at the start of the vector |
Sets the data for the last element in the vector. The pointer to the data being passed in should point to the data type which this vector holds. For example, if this vector 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 vector to set data for |
data | the data to set at the end of the vector |
size_t vector_size | ( | vector | me | ) |
Gets the size being used by the vector.
me | the vector to check |