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_MULTIMAP_STARTING_BUCKETS 16 |
#define | BKTHOMPS_U_MULTIMAP_RESIZE_AT 0.75 |
#define | BKTHOMPS_U_MULTIMAP_RESIZE_RATIO 2 |
#define BKTHOMPS_U_MULTIMAP_RESIZE_AT 0.75 |
#define BKTHOMPS_U_MULTIMAP_RESIZE_RATIO 2 |
#define BKTHOMPS_U_MULTIMAP_STARTING_BUCKETS 16 |
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 | ( | const size_t | key_size, |
const size_t | value_size, | ||
unsigned long(*)(const void *const) | hash, | ||
int(*)(const void *const, const void *const) | key_comparator, | ||
int(*)(const void *const, const void *const) | value_comparator | ||
) |
Initializes an unordered multi-map.
key_size | the size of each key in the unordered multi-map; must be positive |
value_size | the size of each value in the unordered multi-map; must be positive |
hash | the hash function which computes the hash from key; must not be NULL |
key_comparator | the comparator function which compares two keys; must not be NULL |
value_comparator | the comparator function which compares two values; must not be NULL |
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 |