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.
containers.h File Reference
#include <stdlib.h>
Include dependency graph for containers.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
 

Functions

array array_init (size_t element_count, size_t data_size)
 
size_t array_size (array me)
 
void array_copy_to_array (void *arr, array me)
 
void * array_get_data (array me)
 
bk_err array_add_all (array me, void *arr, size_t size)
 
bk_err array_set (array me, size_t index, void *data)
 
bk_err array_get (void *data, array me, size_t index)
 
array array_destroy (array me)
 
deque deque_init (size_t data_size)
 
size_t deque_size (deque me)
 
bk_bool deque_is_empty (deque me)
 
bk_err deque_trim (deque me)
 
void deque_copy_to_array (void *arr, deque me)
 
bk_err deque_add_all (deque me, void *arr, size_t size)
 
bk_err deque_push_front (deque me, void *data)
 
bk_err deque_push_back (deque me, void *data)
 
bk_err deque_pop_front (void *data, deque me)
 
bk_err deque_pop_back (void *data, deque me)
 
bk_err deque_set_first (deque me, void *data)
 
bk_err deque_set_at (deque me, size_t index, void *data)
 
bk_err deque_set_last (deque me, void *data)
 
bk_err deque_get_first (void *data, deque me)
 
bk_err deque_get_at (void *data, deque me, size_t index)
 
bk_err deque_get_last (void *data, deque me)
 
bk_err deque_clear (deque me)
 
deque deque_destroy (deque me)
 
forward_list forward_list_init (size_t data_size)
 
size_t forward_list_size (forward_list me)
 
bk_bool forward_list_is_empty (forward_list me)
 
void forward_list_copy_to_array (void *arr, forward_list me)
 
bk_err forward_list_add_all (forward_list me, void *arr, size_t size)
 
bk_err forward_list_add_first (forward_list me, void *data)
 
bk_err forward_list_add_at (forward_list me, size_t index, void *data)
 
bk_err forward_list_add_last (forward_list me, void *data)
 
bk_err forward_list_remove_first (forward_list me)
 
bk_err forward_list_remove_at (forward_list me, size_t index)
 
bk_err forward_list_remove_last (forward_list me)
 
bk_err forward_list_set_first (forward_list me, void *data)
 
bk_err forward_list_set_at (forward_list me, size_t index, void *data)
 
bk_err forward_list_set_last (forward_list me, void *data)
 
bk_err forward_list_get_first (void *data, forward_list me)
 
bk_err forward_list_get_at (void *data, forward_list me, size_t index)
 
bk_err forward_list_get_last (void *data, forward_list me)
 
void forward_list_clear (forward_list me)
 
forward_list forward_list_destroy (forward_list me)
 
list list_init (size_t data_size)
 
size_t list_size (list me)
 
bk_bool list_is_empty (list me)
 
void list_copy_to_array (void *arr, list me)
 
bk_err list_add_all (list me, void *arr, size_t size)
 
bk_err list_add_first (list me, void *data)
 
bk_err list_add_at (list me, size_t index, void *data)
 
bk_err list_add_last (list me, void *data)
 
bk_err list_remove_first (list me)
 
bk_err list_remove_at (list me, size_t index)
 
bk_err list_remove_last (list me)
 
bk_err list_set_first (list me, void *data)
 
bk_err list_set_at (list me, size_t index, void *data)
 
bk_err list_set_last (list me, void *data)
 
bk_err list_get_first (void *data, list me)
 
bk_err list_get_at (void *data, list me, size_t index)
 
bk_err list_get_last (void *data, list me)
 
void list_clear (list me)
 
list list_destroy (list me)
 
map map_init (size_t key_size, size_t value_size, int(*comparator)(const void *const one, const void *const two))
 
size_t map_size (map me)
 
bk_bool map_is_empty (map me)
 
bk_err map_put (map me, void *key, void *value)
 
bk_bool map_get (void *value, map me, void *key)
 
bk_bool map_contains (map me, void *key)
 
bk_bool map_remove (map me, void *key)
 
void * map_first (map me)
 
void * map_last (map me)
 
void * map_lower (map me, void *key)
 
void * map_higher (map me, void *key)
 
void * map_floor (map me, void *key)
 
void * map_ceiling (map me, void *key)
 
void map_clear (map me)
 
map map_destroy (map me)
 
multimap multimap_init (size_t key_size, size_t value_size, int(*key_comparator)(const void *const one, const void *const two), int(*value_comparator)(const void *const one, const void *const two))
 
size_t multimap_size (multimap me)
 
bk_bool multimap_is_empty (multimap me)
 
bk_err multimap_put (multimap me, void *key, void *value)
 
void multimap_get_start (multimap me, void *key)
 
bk_bool multimap_get_next (void *value, multimap me)
 
size_t multimap_count (multimap me, void *key)
 
bk_bool multimap_contains (multimap me, void *key)
 
bk_bool multimap_remove (multimap me, void *key, void *value)
 
bk_bool multimap_remove_all (multimap me, void *key)
 
void * multimap_first (multimap me)
 
void * multimap_last (multimap me)
 
void * multimap_lower (multimap me, void *key)
 
void * multimap_higher (multimap me, void *key)
 
void * multimap_floor (multimap me, void *key)
 
void * multimap_ceiling (multimap me, void *key)
 
void multimap_clear (multimap me)
 
multimap multimap_destroy (multimap me)
 
multiset multiset_init (size_t key_size, int(*comparator)(const void *const one, const void *const two))
 
size_t multiset_size (multiset me)
 
bk_bool multiset_is_empty (multiset me)
 
bk_err multiset_put (multiset me, void *key)
 
size_t multiset_count (multiset me, void *key)
 
bk_bool multiset_contains (multiset me, void *key)
 
bk_bool multiset_remove (multiset me, void *key)
 
bk_bool multiset_remove_all (multiset me, void *key)
 
void * multiset_first (multiset me)
 
void * multiset_last (multiset me)
 
void * multiset_lower (multiset me, void *key)
 
void * multiset_higher (multiset me, void *key)
 
void * multiset_floor (multiset me, void *key)
 
void * multiset_ceiling (multiset me, void *key)
 
void multiset_clear (multiset me)
 
multiset multiset_destroy (multiset me)
 
priority_queue priority_queue_init (size_t data_size, int(*comparator)(const void *const one, const void *const two))
 
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 *data)
 
bk_bool priority_queue_pop (void *data, priority_queue me)
 
bk_bool priority_queue_front (void *data, priority_queue me)
 
bk_err priority_queue_clear (priority_queue me)
 
priority_queue priority_queue_destroy (priority_queue me)
 
queue queue_init (size_t data_size)
 
size_t queue_size (queue me)
 
bk_bool queue_is_empty (queue me)
 
bk_err queue_trim (queue me)
 
void queue_copy_to_array (void *arr, queue me)
 
bk_err queue_push (queue me, void *data)
 
bk_bool queue_pop (void *data, queue me)
 
bk_bool queue_front (void *data, queue me)
 
bk_bool queue_back (void *data, queue me)
 
bk_err queue_clear (queue me)
 
queue queue_destroy (queue me)
 
set set_init (size_t key_size, int(*comparator)(const void *const one, const void *const two))
 
size_t set_size (set me)
 
bk_bool set_is_empty (set me)
 
bk_err set_put (set me, void *key)
 
bk_bool set_contains (set me, void *key)
 
bk_bool set_remove (set me, void *key)
 
void * set_first (set me)
 
void * set_last (set me)
 
void * set_lower (set me, void *key)
 
void * set_higher (set me, void *key)
 
void * set_floor (set me, void *key)
 
void * set_ceiling (set me, void *key)
 
void set_clear (set me)
 
set set_destroy (set me)
 
stack stack_init (size_t data_size)
 
size_t stack_size (stack me)
 
bk_bool stack_is_empty (stack me)
 
bk_err stack_trim (stack me)
 
void stack_copy_to_array (void *arr, stack me)
 
bk_err stack_push (stack me, void *data)
 
bk_bool stack_pop (void *data, stack me)
 
bk_bool stack_top (void *data, stack me)
 
bk_err stack_clear (stack me)
 
stack stack_destroy (stack me)
 
unordered_map unordered_map_init (size_t key_size, size_t value_size, unsigned long(*hash)(const void *const key), int(*comparator)(const void *const one, const void *const two))
 
bk_err unordered_map_rehash (unordered_map me)
 
size_t unordered_map_size (unordered_map me)
 
bk_bool unordered_map_is_empty (unordered_map me)
 
bk_err unordered_map_put (unordered_map me, void *key, void *value)
 
bk_bool unordered_map_get (void *value, unordered_map me, void *key)
 
bk_bool unordered_map_contains (unordered_map me, void *key)
 
bk_bool unordered_map_remove (unordered_map me, void *key)
 
bk_err unordered_map_clear (unordered_map me)
 
unordered_map unordered_map_destroy (unordered_map me)
 
unordered_multimap unordered_multimap_init (size_t key_size, size_t value_size, unsigned long(*hash)(const void *const key), int(*key_comparator)(const void *const one, const void *const two), int(*value_comparator)(const void *const one, const void *const two))
 
bk_err unordered_multimap_rehash (unordered_multimap me)
 
size_t unordered_multimap_size (unordered_multimap me)
 
bk_bool unordered_multimap_is_empty (unordered_multimap me)
 
bk_err unordered_multimap_put (unordered_multimap me, void *key, void *value)
 
void unordered_multimap_get_start (unordered_multimap me, void *key)
 
bk_bool unordered_multimap_get_next (void *value, unordered_multimap me)
 
size_t unordered_multimap_count (unordered_multimap me, void *key)
 
bk_bool unordered_multimap_contains (unordered_multimap me, void *key)
 
bk_bool unordered_multimap_remove (unordered_multimap me, void *key, void *value)
 
bk_bool unordered_multimap_remove_all (unordered_multimap me, void *key)
 
bk_err unordered_multimap_clear (unordered_multimap me)
 
unordered_multimap unordered_multimap_destroy (unordered_multimap me)
 
unordered_multiset unordered_multiset_init (size_t key_size, unsigned long(*hash)(const void *const key), int(*comparator)(const void *const one, const void *const two))
 
bk_err unordered_multiset_rehash (unordered_multiset me)
 
size_t unordered_multiset_size (unordered_multiset me)
 
bk_bool unordered_multiset_is_empty (unordered_multiset me)
 
bk_err unordered_multiset_put (unordered_multiset me, void *key)
 
size_t unordered_multiset_count (unordered_multiset me, void *key)
 
bk_bool unordered_multiset_contains (unordered_multiset me, void *key)
 
bk_bool unordered_multiset_remove (unordered_multiset me, void *key)
 
bk_bool unordered_multiset_remove_all (unordered_multiset me, void *key)
 
bk_err unordered_multiset_clear (unordered_multiset me)
 
unordered_multiset unordered_multiset_destroy (unordered_multiset me)
 
unordered_set unordered_set_init (size_t key_size, unsigned long(*hash)(const void *const key), int(*comparator)(const void *const one, const void *const two))
 
bk_err unordered_set_rehash (unordered_set me)
 
size_t unordered_set_size (unordered_set me)
 
bk_bool unordered_set_is_empty (unordered_set me)
 
bk_err unordered_set_put (unordered_set me, void *key)
 
bk_bool unordered_set_contains (unordered_set me, void *key)
 
bk_bool unordered_set_remove (unordered_set me, void *key)
 
bk_err unordered_set_clear (unordered_set me)
 
unordered_set unordered_set_destroy (unordered_set me)
 
vector vector_init (size_t data_size)
 
size_t vector_size (vector me)
 
size_t vector_capacity (vector me)
 
bk_bool vector_is_empty (vector me)
 
bk_err vector_reserve (vector me, size_t size)
 
bk_err vector_trim (vector me)
 
void vector_copy_to_array (void *arr, vector me)
 
void * vector_get_data (vector me)
 
bk_err vector_add_all (vector me, void *arr, size_t size)
 
bk_err vector_add_first (vector me, void *data)
 
bk_err vector_add_at (vector me, size_t index, void *data)
 
bk_err vector_add_last (vector me, void *data)
 
bk_err vector_remove_first (vector me)
 
bk_err vector_remove_at (vector me, size_t index)
 
bk_err vector_remove_last (vector me)
 
bk_err vector_set_first (vector me, void *data)
 
bk_err vector_set_at (vector me, size_t index, void *data)
 
bk_err vector_set_last (vector me, void *data)
 
bk_err vector_get_first (void *data, vector me)
 
bk_err vector_get_at (void *data, vector me, size_t index)
 
bk_err vector_get_last (void *data, vector me)
 
bk_err vector_clear (vector me)
 
vector vector_destroy (vector me)
 

Macro Definition Documentation

◆ BK_EINVAL

#define BK_EINVAL   22

◆ BK_ENOMEM

#define BK_ENOMEM   12

◆ BK_ERANGE

#define BK_ERANGE   34

◆ BK_FALSE

#define BK_FALSE   0

◆ BK_OK

#define BK_OK   0

◆ BK_TRUE

#define BK_TRUE   (!BK_FALSE)

◆ BKTHOMPS_CONTAINERS_ARRAY_H

#define BKTHOMPS_CONTAINERS_ARRAY_H

◆ BKTHOMPS_CONTAINERS_DEQUE_H

#define BKTHOMPS_CONTAINERS_DEQUE_H

◆ BKTHOMPS_CONTAINERS_FORWARD_LIST_H

#define BKTHOMPS_CONTAINERS_FORWARD_LIST_H

◆ BKTHOMPS_CONTAINERS_LIST_H

#define BKTHOMPS_CONTAINERS_LIST_H

◆ BKTHOMPS_CONTAINERS_MAP_H

#define BKTHOMPS_CONTAINERS_MAP_H

◆ BKTHOMPS_CONTAINERS_MULTIMAP_H

#define BKTHOMPS_CONTAINERS_MULTIMAP_H

◆ BKTHOMPS_CONTAINERS_MULTISET_H

#define BKTHOMPS_CONTAINERS_MULTISET_H

◆ BKTHOMPS_CONTAINERS_PRIORITY_QUEUE_H

#define BKTHOMPS_CONTAINERS_PRIORITY_QUEUE_H

◆ BKTHOMPS_CONTAINERS_QUEUE_H

#define BKTHOMPS_CONTAINERS_QUEUE_H

◆ BKTHOMPS_CONTAINERS_SET_H

#define BKTHOMPS_CONTAINERS_SET_H

◆ BKTHOMPS_CONTAINERS_STACK_H

#define BKTHOMPS_CONTAINERS_STACK_H

◆ BKTHOMPS_CONTAINERS_UNORDERED_MAP_H

#define BKTHOMPS_CONTAINERS_UNORDERED_MAP_H

◆ BKTHOMPS_CONTAINERS_UNORDERED_MULTIMAP_H

#define BKTHOMPS_CONTAINERS_UNORDERED_MULTIMAP_H

◆ BKTHOMPS_CONTAINERS_UNORDERED_MULTISET_H

#define BKTHOMPS_CONTAINERS_UNORDERED_MULTISET_H

◆ BKTHOMPS_CONTAINERS_UNORDERED_SET_H

#define BKTHOMPS_CONTAINERS_UNORDERED_SET_H

◆ BKTHOMPS_CONTAINERS_VECTOR_H

#define BKTHOMPS_CONTAINERS_VECTOR_H

Typedef Documentation

◆ array

typedef char* array

The array data structure, which is a static contiguous array.

◆ bk_bool

typedef int bk_bool

◆ bk_err

typedef int bk_err

◆ deque

typedef struct internal_deque* deque

The deque data structure, which is a doubly-ended queue.

◆ forward_list

typedef struct internal_forward_list* forward_list

The forward_list data structure, which is a singly-linked list.

◆ list

typedef struct internal_list* list

The list data structure, which is a doubly-linked list.

◆ map

typedef struct internal_map* map

The map data structure, which is a collection of key-value pairs, sorted by keys, keys are unique.

◆ multimap

typedef struct internal_multimap* multimap

The multimap data structure, which is a collection of key-value pairs, sorted by keys.

◆ multiset

typedef struct internal_multiset* multiset

The multiset data structure, which is a collection of key-value pairs, sorted by keys, keys are unique

◆ priority_queue

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.

◆ queue

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.

◆ set

typedef struct internal_set* set

The set data structure, which is a collection of unique keys, sorted by keys.

◆ stack

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.

◆ unordered_map

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

◆ unordered_multimap

typedef struct internal_unordered_multimap* unordered_multimap

The unordered_multimap data structure, which is a collection of key-value pairs, hashed by keys.

◆ unordered_multiset

typedef struct internal_unordered_multiset* unordered_multiset

The unordered_multiset data structure, which is a collection of keys, hashed by keys.

◆ unordered_set

typedef struct internal_unordered_set* unordered_set

The unordered_set data structure, which is a collection of unique keys, hashed by keys.

◆ vector

typedef struct internal_vector* vector

The vector data structure, which is a dynamic contiguous array.

Function Documentation

◆ array_add_all()

bk_err array_add_all ( array  me,
void *const  arr,
const size_t  size 
)

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.

Parameters
methe array to add data to
arrthe raw array to copy data from
sizethe number of elements to copy
Returns
BK_OK if no error
-BK_EINVAL if invalid argument

◆ array_copy_to_array()

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.

Parameters
arrthe initialized raw array to copy the array to
methe array to copy to the raw array

◆ array_destroy()

array array_destroy ( array  me)

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.

Parameters
methe array to free from memory
Returns
NULL

◆ array_get()

bk_err array_get ( void *const  data,
array  me,
const size_t  index 
)

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.

Parameters
datathe data to copy to
methe array to copy from
indexthe index to copy from in the array
Returns
BK_OK if no error
-BK_EINVAL if invalid argument

◆ array_get_data()

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.

Parameters
methe array to get the storage element from
Returns
the storage element of the array

◆ array_init()

array array_init ( const size_t  element_count,
const size_t  data_size 
)

Initializes an array.

Parameters
element_countthe number of elements in the array; must not be negative
data_sizethe size of each element in the array; must be positive
Returns
the newly-initialized array, or NULL if it was not successfully initialized due to either invalid input arguments or memory allocation error

◆ array_set()

bk_err array_set ( array  me,
const size_t  index,
void *const  data 
)

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.

Parameters
methe array to set data for
indexthe location to set data at in the array
datathe data to set at the location in the array
Returns
BK_OK if no error
-BK_EINVAL if invalid argument

◆ array_size()

size_t array_size ( array  me)

Gets the size of the array.

Parameters
methe array to check
Returns
the size of the array

◆ deque_add_all()

bk_err deque_add_all ( deque  me,
void *const  arr,
const size_t  size 
)

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.

Parameters
methe deque to add data to
arrthe array to copy data from
sizethe number of elements to copy
Returns
BK_OK if no error
-BK_ENOMEM if out of memory
-BK_ERANGE if size has reached representable limit

◆ deque_clear()

bk_err deque_clear ( deque  me)

Clears the deque and sets it to the original state from initialization.

Parameters
methe deque to clear
Returns
BK_OK if no error
-BK_ENOMEM if out of memory

◆ deque_copy_to_array()

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.

Parameters
arrthe initialized array to copy the deque to
methe deque to copy to the array

◆ deque_destroy()

deque deque_destroy ( deque  me)

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.

Parameters
methe deque to destroy
Returns
NULL

◆ deque_get_at()

bk_err deque_get_at ( void *const  data,
deque  me,
size_t  index 
)

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.

Parameters
datathe data to set
methe deque to set the value of
indexthe index to set at
Returns
BK_OK if no error
-BK_EINVAL if invalid argument

◆ deque_get_first()

bk_err deque_get_first ( void *const  data,
deque  me 
)

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.

Parameters
datathe data to set
methe deque to set the value of
Returns
BK_OK if no error
-BK_EINVAL if invalid argument

◆ deque_get_last()

bk_err deque_get_last ( void *const  data,
deque  me 
)

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.

Parameters
datathe data to set
methe deque to set the value of
Returns
BK_OK if no error
-BK_EINVAL if invalid argument

◆ deque_init()

deque deque_init ( const size_t  data_size)

Initializes a deque.

Parameters
data_sizethe size of each element in the deque; must be positive
Returns
the newly-initialized deque, or NULL if it was not successfully initialized due to either invalid input arguments or memory allocation error

◆ deque_is_empty()

bk_bool deque_is_empty ( deque  me)

Determines if the deque is empty. It is empty if it has no elements.

Parameters
methe deque to check if empty
Returns
BK_TRUE if the deque is empty, otherwise BK_FALSE

◆ deque_pop_back()

bk_err deque_pop_back ( void *const  data,
deque  me 
)

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.

Parameters
datathe value to copy to
methe deque to remove from
Returns
BK_OK if no error
-BK_EINVAL if invalid argument

◆ deque_pop_front()

bk_err deque_pop_front ( void *const  data,
deque  me 
)

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.

Parameters
datathe value to copy to
methe deque to remove from
Returns
BK_OK if no error
-BK_EINVAL if invalid argument

◆ deque_push_back()

bk_err deque_push_back ( deque  me,
void *const  data 
)

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.

Parameters
methe deque to add an element to
datathe element to add
Returns
BK_OK if no error
-BK_ENOMEM if out of memory
-BK_ERANGE if size has reached representable limit

◆ deque_push_front()

bk_err deque_push_front ( deque  me,
void *const  data 
)

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.

Parameters
methe deque to add an element to
datathe element to add
Returns
BK_OK if no error
-BK_ENOMEM if out of memory
-BK_ERANGE if size has reached representable limit

◆ deque_set_at()

bk_err deque_set_at ( deque  me,
size_t  index,
void *const  data 
)

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.

Parameters
methe deque to set the value of
indexthe index to set at
datathe data to set
Returns
BK_OK if no error
-BK_EINVAL if invalid argument

◆ deque_set_first()

bk_err deque_set_first ( deque  me,
void *const  data 
)

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.

Parameters
methe deque to set the value of
datathe data to set
Returns
BK_OK if no error
-BK_EINVAL if invalid argument

◆ deque_set_last()

bk_err deque_set_last ( deque  me,
void *const  data 
)

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.

Parameters
methe deque to set the value of
datathe data to set
Returns
BK_OK if no error
-BK_EINVAL if invalid argument

◆ deque_size()

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.

Parameters
methe deque to check the size of
Returns
the size of the deque

◆ deque_trim()

bk_err deque_trim ( deque  me)

Trims the deque so that it does not use memory which does not need to be used.

Parameters
methe deque to trim
Returns
BK_OK if no error
-BK_ENOMEM if out of memory

◆ forward_list_add_all()

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.

Parameters
methe singly-linked list to add data to
arrthe array to copy data from
sizethe number of elements to copy
Returns
BK_OK if no error
-BK_ENOMEM if out of memory
-BK_ERANGE if size has reached representable limit

◆ forward_list_add_at()

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.

Parameters
methe singly-linked list to add data to
indexthe index to add the data at
datathe data to add to the singly-linked list
Returns
BK_OK if no error
-BK_ENOMEM if out of memory
-BK_EINVAL if invalid argument

◆ forward_list_add_first()

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.

Parameters
methe singly-linked list to add data to
datathe data to add to the singly-linked list
Returns
BK_OK if no error
-BK_ENOMEM if out of memory

◆ forward_list_add_last()

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.

Parameters
methe singly-linked list to add data to
datathe data to add to the singly-linked list
Returns
BK_OK if no error
-BK_ENOMEM if out of memory

◆ forward_list_clear()

void forward_list_clear ( forward_list  me)

Clears all elements from the singly-linked list.

Parameters
methe singly-linked list to clear

◆ forward_list_copy_to_array()

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.

Parameters
arrthe initialized array to copy the singly-linked list to
methe singly-linked list to copy to the array

◆ forward_list_destroy()

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.

Parameters
methe singly-linked list to destroy
Returns
NULL

◆ forward_list_get_at()

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.

Parameters
datathe data to get
methe singly-linked list to get data from
indexthe index to get data from
Returns
BK_OK if no error
-BK_EINVAL if invalid argument

◆ forward_list_get_first()

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.

Parameters
datathe data to get
methe singly-linked list to get data from
Returns
BK_OK if no error
-BK_EINVAL if invalid argument

◆ forward_list_get_last()

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.

Parameters
datathe data to get
methe singly-linked list to get data from
Returns
BK_OK if no error
-BK_EINVAL if invalid argument

◆ forward_list_init()

forward_list forward_list_init ( const size_t  data_size)

Initializes a singly-linked list.

Parameters
data_sizethe size of data to store; must be positive
Returns
the newly-initialized singly-linked list, or NULL if it was not successfully initialized due to either invalid input arguments or memory allocation error

◆ forward_list_is_empty()

bk_bool forward_list_is_empty ( forward_list  me)

Determines if the singly-linked list is empty.

Parameters
methe singly-linked list to check
Returns
BK_TRUE if the singly-linked list is empty, otherwise BK_FALSE

◆ forward_list_remove_at()

bk_err forward_list_remove_at ( forward_list  me,
const size_t  index 
)

Removes data from the singly-linked list at the specified index.

Parameters
methe singly-linked list to remove data from
indexthe index to remove from
Returns
BK_OK if no error
-BK_EINVAL if invalid argument

◆ forward_list_remove_first()

bk_err forward_list_remove_first ( forward_list  me)

Removes the first piece of data from the singly-linked list.

Parameters
methe singly-linked list to remove data from
Returns
BK_OK if no error
-BK_EINVAL if invalid argument

◆ forward_list_remove_last()

bk_err forward_list_remove_last ( forward_list  me)

Removes the last piece of data from the singly-linked list.

Parameters
methe singly-linked list to remove data from
Returns
BK_OK if no error
-BK_EINVAL if invalid argument

◆ forward_list_set_at()

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.

Parameters
methe singly-linked list to set data for
indexthe index to set data in the singly-linked list
datathe data to set in the singly-linked list
Returns
BK_OK if no error
-BK_EINVAL if invalid argument

◆ forward_list_set_first()

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.

Parameters
methe singly-linked list to set data for
datathe data to set in the singly-linked list
Returns
BK_OK if no error
-BK_EINVAL if invalid argument

◆ forward_list_set_last()

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.

Parameters
methe singly-linked list to set data for
datathe data to set in the singly-linked list
Returns
BK_OK if no error
-BK_EINVAL if invalid argument

◆ forward_list_size()

size_t forward_list_size ( forward_list  me)

Gets the number of elements in the singly-linked list.

Parameters
methe singly-linked list to check
Returns
the number of elements

◆ list_add_all()

bk_err list_add_all ( list  me,
void *const  arr,
const size_t  size 
)

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.

Parameters
methe doubly-linked list to add data to
arrthe array to copy data from
sizethe number of elements to copy
Returns
BK_OK if no error
-BK_ENOMEM if out of memory
-BK_ERANGE if size has reached representable limit

◆ list_add_at()

bk_err list_add_at ( list  me,
const size_t  index,
void *const  data 
)

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.

Parameters
methe doubly-linked list to add data to
indexthe index to add the data at
datathe data to add to the doubly-linked list
Returns
BK_OK if no error
-BK_ENOMEM if out of memory
-BK_EINVAL if invalid argument

◆ list_add_first()

bk_err list_add_first ( list  me,
void *const  data 
)

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.

Parameters
methe doubly-linked list to add data to
datathe data to add to the doubly-linked list
Returns
BK_OK if no error
-BK_ENOMEM if out of memory

◆ list_add_last()

bk_err list_add_last ( list  me,
void *const  data 
)

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.

Parameters
methe doubly-linked list to add data to
datathe data to add to the doubly-linked list
Returns
BK_OK if no error
-BK_ENOMEM if out of memory

◆ list_clear()

void list_clear ( list  me)

Clears all elements from the doubly-linked list.

Parameters
methe doubly-linked list to clear

◆ list_copy_to_array()

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.

Parameters
arrthe initialized array to copy the doubly-linked list to
methe doubly-linked list to copy to the array

◆ list_destroy()

list list_destroy ( list  me)

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.

Parameters
methe doubly-linked list to destroy
Returns
NULL

◆ list_get_at()

bk_err list_get_at ( void *const  data,
list  me,
const size_t  index 
)

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.

Parameters
datathe data to get
methe doubly-linked list to get data from
indexthe index to get data from
Returns
BK_OK if no error
-BK_EINVAL if invalid argument

◆ list_get_first()

bk_err list_get_first ( void *const  data,
list  me 
)

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.

Parameters
datathe data to get
methe doubly-linked list to get data from
Returns
BK_OK if no error
-BK_EINVAL if invalid argument

◆ list_get_last()

bk_err list_get_last ( void *const  data,
list  me 
)

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.

Parameters
datathe data to get
methe doubly-linked list to get data from
Returns
BK_OK if no error
-BK_EINVAL if invalid argument

◆ list_init()

list list_init ( const size_t  data_size)

Initializes a doubly-linked list.

Parameters
data_sizethe size of data to store; must be positive
Returns
the newly-initialized doubly-linked list, or NULL if it was not successfully initialized due to either invalid input arguments or memory allocation error

◆ list_is_empty()

bk_bool list_is_empty ( list  me)

Determines if the doubly-linked list is empty.

Parameters
methe doubly-linked list to check
Returns
BK_TRUE if the list is empty, otherwise BK_FALSE

◆ list_remove_at()

bk_err list_remove_at ( list  me,
const size_t  index 
)

Removes data from the doubly-linked list at the specified index.

Parameters
methe doubly-linked list to remove data from
indexthe index to remove from
Returns
BK_OK if no error
-BK_EINVAL if invalid argument

◆ list_remove_first()

bk_err list_remove_first ( list  me)

Removes the first piece of data from the doubly-linked list.

Parameters
methe doubly-linked list to remove data from
Returns
BK_OK if no error
-BK_EINVAL if invalid argument

◆ list_remove_last()

bk_err list_remove_last ( list  me)

Removes the last piece of data from the doubly-linked list.

Parameters
methe doubly-linked list to remove data from
Returns
BK_OK if no error
-BK_EINVAL if invalid argument

◆ list_set_at()

bk_err list_set_at ( list  me,
const size_t  index,
void *const  data 
)

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.

Parameters
methe doubly-linked list to set data for
indexthe index to set data in the doubly-linked list
datathe data to set in the doubly-linked list
Returns
BK_OK if no error
-BK_EINVAL if invalid argument

◆ list_set_first()

bk_err list_set_first ( list  me,
void *const  data 
)

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.

Parameters
methe doubly-linked list to set data for
datathe data to set in the doubly-linked list
Returns
BK_OK if no error
-BK_EINVAL if invalid argument

◆ list_set_last()

bk_err list_set_last ( list  me,
void *const  data 
)

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.

Parameters
methe doubly-linked list to set data for
datathe data to set in the doubly-linked list
Returns
BK_OK if no error
-BK_EINVAL if invalid argument

◆ list_size()

size_t list_size ( list  me)

Gets the number of elements in the doubly-linked list.

Parameters
methe doubly-linked list to check
Returns
the number of elements

◆ map_ceiling()

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.

Parameters
methe map to get the ceiling key from
keythe key to use for comparison
Returns
the key which is the ceiling, or NULL if it does not exist

◆ map_clear()

void map_clear ( map  me)

Clears the key-value pairs from the map.

Parameters
methe map to clear

◆ map_contains()

bk_bool map_contains ( map  me,
void *const  key 
)

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.

Parameters
methe map to check for the element
keythe key to check
Returns
BK_TRUE if the map contained the element, otherwise BK_FALSE

◆ map_destroy()

map map_destroy ( map  me)

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.

Parameters
methe map to free from memory
Returns
NULL

◆ map_first()

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.

Parameters
methe map to get the key from
Returns
the lowest key in this map, or NULL if it is empty

◆ map_floor()

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.

Parameters
methe map to get the floor key from
keythe key to use for comparison
Returns
the key which is the floor, or NULL if it does not exist

◆ map_get()

bk_bool map_get ( void *const  value,
map  me,
void *const  key 
)

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.

Parameters
valuethe value to copy to
methe map to get from
keythe key to search for
Returns
BK_TRUE if the map contained the key-value pair, otherwise BK_FALSE

◆ map_higher()

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.

Parameters
methe map to get the higher key from
keythe key to use for comparison
Returns
the key which is strictly higher, or NULL if it does not exist

◆ map_init()

map map_init ( size_t  key_size,
size_t  value_size,
int(*)(const void *const one, const void *const two)  comparator 
)

◆ map_is_empty()

bk_bool map_is_empty ( map  me)

Determines whether or not the map is empty.

Parameters
methe map to check
Returns
BK_TRUE if the map is empty, otherwise BK_FALSE

◆ map_last()

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.

Parameters
methe map to get the key from
Returns
the highest key in this map, or NULL if it is empty

◆ map_lower()

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.

Parameters
methe map to get the lower key from
keythe key to use for comparison
Returns
the key which is strictly lower, or NULL if it does not exist

◆ map_put()

bk_err map_put ( map  me,
void *const  key,
void *const  value 
)

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.

Parameters
methe map to add to
keythe key to add
valuethe value to add
Returns
BK_OK if no error
-BK_ENOMEM if out of memory

◆ map_remove()

bk_bool map_remove ( map  me,
void *const  key 
)

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.

Parameters
methe map to remove an element from
keythe key to remove
Returns
BK_TRUE if the map contained the key-value pair, otherwise BK_FALSE

◆ map_size()

size_t map_size ( map  me)

Gets the size of the map.

Parameters
methe map to check
Returns
the size of the map

◆ multimap_ceiling()

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.

Parameters
methe multi-map to get the ceiling key from
keythe key to use for comparison
Returns
the key which is the ceiling, or NULL if it does not exist

◆ multimap_clear()

void multimap_clear ( multimap  me)

Clears the key-value pairs from the multi-map.

Parameters
methe multi-map to clear

◆ multimap_contains()

bk_bool multimap_contains ( multimap  me,
void *const  key 
)

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.

Parameters
methe multi-map to check for the key
keythe key to check
Returns
BK_TRUE if the multi-map contained the key, otherwise BK_FALSE

◆ multimap_count()

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.

Parameters
methe multi-map to check for the key
keythe key to check
Returns
the number of times the key appears in the multi-map

◆ multimap_destroy()

multimap multimap_destroy ( multimap  me)

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.

Parameters
methe multi-map to free from memory
Returns
NULL

◆ multimap_first()

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.

Parameters
methe multi-map to get the key from
Returns
the lowest key in this multi-map, or NULL if it is empty

◆ multimap_floor()

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.

Parameters
methe multi-map to get the floor key from
keythe key to use for comparison
Returns
the key which is the floor, or NULL if it does not exist

◆ multimap_get_next()

bk_bool multimap_get_next ( void *const  value,
multimap  me 
)

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.

Parameters
valuethe value to be copied to from iteration
methe multi-map to iterate over
Returns
BK_TRUE if there exist more values for the key which is being iterated over, otherwise BK_FALSE

◆ multimap_get_start()

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.

Parameters
methe multi-map to start the iterator for
keythe key to start the iterator for

◆ multimap_higher()

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.

Parameters
methe multi-map to get the higher key from
keythe key to use for comparison
Returns
the key which is strictly higher, or NULL if it does not exist

◆ multimap_init()

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 
)

◆ multimap_is_empty()

bk_bool multimap_is_empty ( multimap  me)

Determines whether or not the multi-map is empty.

Parameters
methe multi-map to check
Returns
BK_TRUE if the multi-map is empty, otherwise BK_FALSE

◆ multimap_last()

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.

Parameters
methe multi-map to get the key from
Returns
the highest key in this multi-map, or NULL if it is empty

◆ multimap_lower()

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.

Parameters
methe multi-map to get the lower key from
keythe key to use for comparison
Returns
the key which is strictly lower, or NULL if it does not exist

◆ multimap_put()

bk_err multimap_put ( multimap  me,
void *const  key,
void *const  value 
)

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.

Parameters
methe multi-map to add to
keythe key to add
valuethe value to add
Returns
BK_OK if no error
-BK_ENOMEM if out of memory

◆ multimap_remove()

bk_bool multimap_remove ( multimap  me,
void *const  key,
void *const  value 
)

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.

Parameters
methe multi-map to remove a key from
keythe key to remove
valuethe value to remove
Returns
BK_TRUE if the multi-map contained the key, otherwise BK_FALSE

◆ multimap_remove_all()

bk_bool multimap_remove_all ( multimap  me,
void *const  key 
)

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.

Parameters
methe multi-map to remove a key-value pair from
keythe key to remove
Returns
BK_TRUE if the multi-map contained the key, otherwise BK_FALSE

◆ multimap_size()

size_t multimap_size ( multimap  me)

Gets the size of the multi-map.

Parameters
methe multi-map to check
Returns
the size of the multi-map

◆ multiset_ceiling()

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.

Parameters
methe multi-set to get the ceiling key from
keythe key to use for comparison
Returns
the key which is the ceiling, or NULL if it does not exist

◆ multiset_clear()

void multiset_clear ( multiset  me)

Clears the keys from the multiset.

Parameters
methe multi-set to clear

◆ multiset_contains()

bk_bool multiset_contains ( multiset  me,
void *const  key 
)

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.

Parameters
methe multi-set to check for the key
keythe key to check
Returns
BK_TRUE if the multiset contained the key, otherwise BK_FALSE

◆ multiset_count()

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.

Parameters
methe multi-set to check for the count
keythe key to check
Returns
the count of a specific key in the multi-set

◆ multiset_destroy()

multiset multiset_destroy ( multiset  me)

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.

Parameters
methe multi-set to free from memory
Returns
NULL

◆ multiset_first()

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.

Parameters
methe multi-set to get the key from
Returns
the lowest key in this multi-set, or NULL if it is empty

◆ multiset_floor()

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.

Parameters
methe multi-set to get the floor key from
keythe key to use for comparison
Returns
the key which is the floor, or NULL if it does not exist

◆ multiset_higher()

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.

Parameters
methe multi-set to get the higher key from
keythe key to use for comparison
Returns
the key which is strictly higher, or NULL if it does not exist

◆ multiset_init()

multiset multiset_init ( size_t  key_size,
int(*)(const void *const one, const void *const two)  comparator 
)

◆ multiset_is_empty()

bk_bool multiset_is_empty ( multiset  me)

Determines whether or not the multi-set is empty.

Parameters
methe multi-set to check
Returns
BK_TRUE if the multi-set is empty, otherwise BK_FALSE

◆ multiset_last()

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.

Parameters
methe multi-set to get the key from
Returns
the highest key in this multi-set, or NULL if it is empty

◆ multiset_lower()

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.

Parameters
methe multi-set to get the lower key from
keythe key to use for comparison
Returns
the key which is strictly lower, or NULL if it does not exist

◆ multiset_put()

bk_err multiset_put ( multiset  me,
void *const  key 
)

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.

Parameters
methe multi-set to add to
keythe key to add
Returns
BK_OK if no error
-BK_ENOMEM if out of memory

◆ multiset_remove()

bk_bool multiset_remove ( multiset  me,
void *const  key 
)

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.

Parameters
methe multi-set to remove a key from
keythe key to remove
Returns
BK_TRUE if the multi-set contained the key, otherwise BK_FALSE

◆ multiset_remove_all()

bk_bool multiset_remove_all ( multiset  me,
void *const  key 
)

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.

Parameters
methe multi-set to remove a key from
keythe key to remove
Returns
BK_TRUE if the multi-set contained the key, otherwise BK_FALSE

◆ multiset_size()

size_t multiset_size ( multiset  me)

Gets the size of the multi-set.

Parameters
methe multi-set to check
Returns
the size of the multi-set

◆ priority_queue_clear()

bk_err priority_queue_clear ( priority_queue  me)

Clears the elements from the priority queue.

Parameters
methe priority queue to clear
Returns
BK_OK if no error
-BK_ENOMEM if out of memory

◆ priority_queue_destroy()

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.

Parameters
methe priority queue to free from memory
Returns
NULL

◆ priority_queue_front()

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.

Parameters
datathe out copy of the highest priority element in the priority queue
methe priority queue to copy from
Returns
BK_TRUE if the priority queue contained elements, otherwise BK_FALSE

◆ priority_queue_init()

priority_queue priority_queue_init ( size_t  data_size,
int(*)(const void *const one, const void *const two)  comparator 
)

◆ priority_queue_is_empty()

bk_bool priority_queue_is_empty ( priority_queue  me)

Determines whether or not the priority queue is empty.

Parameters
methe priority queue to check
Returns
BK_TRUE if the priority queue is empty, otherwise BK_FALSE

◆ priority_queue_pop()

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.

Parameters
datathe data to have copied from the priority queue
methe priority queue to pop the next element from
Returns
BK_TRUE if the priority queue contained elements, otherwise BK_FALSE

◆ priority_queue_push()

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.

Parameters
methe priority queue to add an element to
datathe data to add to the queue
Returns
BK_OK if no error
-BK_ENOMEM if out of memory
-BK_ERANGE if size has reached representable limit

◆ priority_queue_size()

size_t priority_queue_size ( priority_queue  me)

Gets the size of the priority queue.

Parameters
methe priority queue to check
Returns
the size of the priority queue

◆ queue_back()

bk_bool queue_back ( void *const  data,
queue  me 
)

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.

Parameters
datathe copy of the back element of the queue
methe queue to copy from
Returns
BK_TRUE if the queue contained elements, otherwise BK_FALSE

◆ queue_clear()

bk_err queue_clear ( queue  me)

Clears the queue and sets it to the original state from initialization.

Parameters
methe queue to clear
Returns
BK_OK if no error
-BK_ENOMEM if out of memory

◆ queue_copy_to_array()

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.

Parameters
arrthe initialized array to copy the queue to
methe queue to copy to the array

◆ queue_destroy()

queue queue_destroy ( queue  me)

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.

Parameters
methe queue to destroy
Returns
NULL

◆ queue_front()

bk_bool queue_front ( void *const  data,
queue  me 
)

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.

Parameters
datathe copy of the front element of the queue
methe queue to copy from
Returns
BK_TRUE if the queue contained elements, otherwise BK_FALSE

◆ queue_init()

queue queue_init ( const size_t  data_size)

Initializes a queue.

Parameters
data_sizethe size of each element; must be positive
Returns
the newly-initialized queue, or NULL if it was not successfully initialized due to either invalid input arguments or memory allocation error

◆ queue_is_empty()

bk_bool queue_is_empty ( queue  me)

Determines if the queue is empty. The queue is empty if it contains no elements.

Parameters
methe queue to check if empty
Returns
BK_TRUE if the queue is empty, otherwise BK_FALSE

◆ queue_pop()

bk_bool queue_pop ( void *const  data,
queue  me 
)

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.

Parameters
datathe data to have copied from the queue
methe queue to pop the next element from
Returns
BK_TRUE if the queue contained elements, otherwise BK_FALSE

◆ queue_push()

bk_err queue_push ( queue  me,
void *const  data 
)

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.

Parameters
methe queue to add an element to
datathe data to add to the queue
Returns
BK_OK if no error
-BK_ENOMEM if out of memory
-BK_ERANGE if size has reached representable limit

◆ queue_size()

size_t queue_size ( queue  me)

Determines the size of the queue.

Parameters
methe queue to get size of
Returns
the queue size

◆ queue_trim()

bk_err queue_trim ( queue  me)

Frees the unused memory in the queue.

Parameters
methe queue to trim
Returns
BK_OK if no error
-BK_ENOMEM if out of memory

◆ set_ceiling()

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.

Parameters
methe set to get the ceiling key from
keythe key to use for comparison
Returns
the key which is the ceiling, or NULL if it does not exist

◆ set_clear()

void set_clear ( set  me)

Clears the keys from the set.

Parameters
methe set to clear

◆ set_contains()

bk_bool set_contains ( set  me,
void *const  key 
)

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.

Parameters
methe set to check for the key
keythe key to check
Returns
BK_TRUE if the set contained the key, otherwise BK_FALSE

◆ set_destroy()

set set_destroy ( set  me)

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.

Parameters
methe set to free from memory
Returns
NULL

◆ set_first()

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.

Parameters
methe set to get the key from
Returns
the lowest key in this set, or NULL if it is empty

◆ set_floor()

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.

Parameters
methe set to get the floor key from
keythe key to use for comparison
Returns
the key which is the floor, or NULL if it does not exist

◆ set_higher()

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.

Parameters
methe set to get the higher key from
keythe key to use for comparison
Returns
the key which is strictly higher, or NULL if it does not exist

◆ set_init()

set set_init ( size_t  key_size,
int(*)(const void *const one, const void *const two)  comparator 
)

◆ set_is_empty()

bk_bool set_is_empty ( set  me)

Determines whether or not the set is empty.

Parameters
methe set to check
Returns
BK_TRUE if the set is empty, otherwise BK_FALSE

◆ set_last()

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.

Parameters
methe set to get the key from
Returns
the highest key in this set, or NULL if it is empty

◆ set_lower()

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.

Parameters
methe set to get the lower key from
keythe key to use for comparison
Returns
the key which is strictly lower, or NULL if it does not exist

◆ set_put()

bk_err set_put ( set  me,
void *const  key 
)

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.

Parameters
methe set to add to
keythe key to add
Returns
BK_OK if no error
-BK_ENOMEM if out of memory

◆ set_remove()

bk_bool set_remove ( set  me,
void *const  key 
)

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.

Parameters
methe set to remove an key from
keythe key to remove
Returns
BK_TRUE if the set contained the key, otherwise BK_FALSE

◆ set_size()

size_t set_size ( set  me)

Gets the size of the set.

Parameters
methe set to check
Returns
the size of the set

◆ stack_clear()

bk_err stack_clear ( stack  me)

Clears the stack and sets it to the state from original initialization.

Parameters
methe stack to clear
Returns
BK_OK if no error
-BK_ENOMEM if out of memory

◆ stack_copy_to_array()

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.

Parameters
arrthe initialized array to copy the stack to
methe stack to copy to the array

◆ stack_destroy()

stack stack_destroy ( stack  me)

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.

Parameters
methe stack to destroy
Returns
NULL

◆ stack_init()

stack stack_init ( const size_t  data_size)

Initializes a stack.

Parameters
data_sizethe size of each data element in the stack; must be positive
Returns
the newly-initialized stack, or NULL if it was not successfully initialized due to either invalid input arguments or memory allocation error

◆ stack_is_empty()

bk_bool stack_is_empty ( stack  me)

Determines if the stack is empty, meaning it contains no elements.

Parameters
methe stack to check if empty
Returns
BK_TRUE if the stack is empty, otherwise BK_FALSE

◆ stack_pop()

bk_bool stack_pop ( void *const  data,
stack  me 
)

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.

Parameters
datathe copy of the element being removed
methe stack to remove the top element from
Returns
BK_TRUE if the stack contained elements, otherwise BK_FALSE

◆ stack_push()

bk_err stack_push ( stack  me,
void *const  data 
)

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.

Parameters
methe stack to add an element to
datathe data to add to the stack
Returns
BK_OK if no error
-BK_ENOMEM if out of memory
-BK_ERANGE if size has reached representable limit

◆ stack_size()

size_t stack_size ( stack  me)

Determines the size of the stack.

Parameters
methe stack to check size of
Returns
the size of the stack

◆ stack_top()

bk_bool stack_top ( void *const  data,
stack  me 
)

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.

Parameters
datathe copy of the top element of the stack
methe stack to copy from
Returns
BK_TRUE if the stack contained elements, otherwise BK_FALSE

◆ stack_trim()

bk_err stack_trim ( stack  me)

Frees unused memory from the stack.

Parameters
methe stack to trim
Returns
BK_OK if no error
-BK_ENOMEM if out of memory

◆ unordered_map_clear()

bk_err unordered_map_clear ( unordered_map  me)

Clears the key-value pairs from the unordered map.

Parameters
methe unordered map to clear
Returns
BK_OK if no error
-BK_ENOMEM if out of memory

◆ unordered_map_contains()

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.

Parameters
methe unordered map to check for the key
keythe key to check
Returns
BK_TRUE if the unordered map contained the key, otherwise BK_FALSE

◆ unordered_map_destroy()

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.

Parameters
methe unordered map to free from memory
Returns
NULL

◆ unordered_map_get()

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.

Parameters
valuethe value to copy to
methe unordered map to get from
keythe key to search for
Returns
BK_TRUE if the unordered map contained the key-value pair, otherwise BK_FALSE

◆ unordered_map_init()

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 
)

◆ unordered_map_is_empty()

bk_bool unordered_map_is_empty ( unordered_map  me)

Determines whether or not the unordered map is empty.

Parameters
methe unordered map to check
Returns
BK_TRUE if the unordered map is empty, otherwise BK_FALSE

◆ unordered_map_put()

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.

Parameters
methe unordered map to add to
keythe key to add
valuethe value to add
Returns
BK_OK if no error
-BK_ENOMEM if out of memory

◆ unordered_map_rehash()

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.

Parameters
methe unordered map to rehash
Returns
BK_OK if no error
-BK_ENOMEM if out of memory

◆ unordered_map_remove()

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.

Parameters
methe unordered map to remove a key from
keythe key to remove
Returns
BK_TRUE if the unordered map contained the key, otherwise BK_FALSE

◆ unordered_map_size()

size_t unordered_map_size ( unordered_map  me)

Gets the size of the unordered map.

Parameters
methe unordered map to check
Returns
the size of the unordered map

◆ unordered_multimap_clear()

bk_err unordered_multimap_clear ( unordered_multimap  me)

Clears the key-value pairs from the unordered multi-map.

Parameters
methe unordered multi-map to clear
Returns
BK_OK if no error
-BK_ENOMEM if out of memory

◆ unordered_multimap_contains()

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.

Parameters
methe unordered multi-map to check for the key
keythe key to check
Returns
BK_TRUE if the unordered multi-map contained the key, otherwise BK_FALSE

◆ unordered_multimap_count()

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.

Parameters
methe unordered multi-map to check for the key
keythe key to check
Returns
the number of times the key appears in the unordered multi-map

◆ unordered_multimap_destroy()

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.

Parameters
methe unordered multi-map to free from memory
Returns
NULL

◆ unordered_multimap_get_next()

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.

Parameters
valuethe value to be copied to from iteration
methe unordered multi-map to iterate over
Returns
BK_TRUE if there exist more values for the key which is being iterated over, otherwise BK_FALSE

◆ unordered_multimap_get_start()

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.

Parameters
methe unordered multi-map to start the iterator for
keythe key to start the iterator for

◆ unordered_multimap_init()

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 
)

◆ unordered_multimap_is_empty()

bk_bool unordered_multimap_is_empty ( unordered_multimap  me)

Determines whether or not the unordered multi-map is empty.

Parameters
methe unordered multi-map to check
Returns
BK_TRUE if the unordered multi-map is empty, otherwise BK_FALSE

◆ unordered_multimap_put()

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.

Parameters
methe unordered multi-map to add to
keythe key to add
valuethe value to add
Returns
BK_OK if no error
-BK_ENOMEM if out of memory

◆ unordered_multimap_rehash()

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.

Parameters
methe unordered multi-map to rehash
Returns
BK_OK if no error
-BK_ENOMEM if out of memory

◆ unordered_multimap_remove()

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.

Parameters
methe unordered multi-map to remove a key from
keythe key to remove
valuethe value to remove
Returns
BK_TRUE if the unordered multi-map contained the key, otherwise BK_FALSE

◆ unordered_multimap_remove_all()

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.

Parameters
methe unordered multi-map to remove a key-value pair from
keythe key to remove
Returns
BK_TRUE if the unordered multi-map contained the key, otherwise BK_FALSE

◆ unordered_multimap_size()

size_t unordered_multimap_size ( unordered_multimap  me)

Gets the size of the unordered multi-map.

Parameters
methe unordered multi-map to check
Returns
the size of the unordered multi-map

◆ unordered_multiset_clear()

bk_err unordered_multiset_clear ( unordered_multiset  me)

Clears the keys from the unordered multi-set.

Parameters
methe unordered multi-set to clear
Returns
BK_OK if no error
-BK_ENOMEM if out of memory

◆ unordered_multiset_contains()

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.

Parameters
methe unordered multi-set to check for the key
keythe key to check
Returns
BK_TRUE if the unordered multi-set contained the key, otherwise BK_FALSE

◆ unordered_multiset_count()

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.

Parameters
methe unordered multi-set to check for the count
keythe element to check
Returns
the count of a specific key in the unordered multi-set

◆ unordered_multiset_destroy()

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.

Parameters
methe unordered multi-set to free from memory
Returns
NULL

◆ unordered_multiset_init()

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 
)

◆ unordered_multiset_is_empty()

bk_bool unordered_multiset_is_empty ( unordered_multiset  me)

Determines whether or not the unordered multi-set is empty.

Parameters
methe unordered multi-set to check
Returns
BK_TRUE if the unordered multi-set is empty, otherwise BK_FALSE

◆ unordered_multiset_put()

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.

Parameters
methe unordered multi-set to add to
keythe element to add
Returns
BK_OK if no error
-BK_ENOMEM if out of memory

◆ unordered_multiset_rehash()

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.

Parameters
methe unordered multi-set to rehash
Returns
BK_OK if no error
-BK_ENOMEM if out of memory

◆ unordered_multiset_remove()

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.

Parameters
methe unordered multi-set to remove a key from
keythe key to remove
Returns
BK_TRUE if the unordered multi-set contained the key, otherwise BK_FALSE

◆ unordered_multiset_remove_all()

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.

Parameters
methe unordered multi-set to remove a key from
keythe key to remove
Returns
BK_TRUE if the unordered multi-set contained the key, otherwise BK_FALSE

◆ unordered_multiset_size()

size_t unordered_multiset_size ( unordered_multiset  me)

Gets the size of the unordered multi-set.

Parameters
methe unordered multi-set to check
Returns
the size of the unordered multi-set

◆ unordered_set_clear()

bk_err unordered_set_clear ( unordered_set  me)

Clears the keys from the unordered set.

Parameters
methe unordered set to clear
Returns
BK_OK if no error
-BK_ENOMEM if out of memory

◆ unordered_set_contains()

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.

Parameters
methe unordered set to check for the element
keythe element to check
Returns
BK_TRUE if the unordered set contained the element, otherwise BK_FALSE

◆ unordered_set_destroy()

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.

Parameters
methe unordered set to free from memory
Returns
NULL

◆ unordered_set_init()

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 
)

◆ unordered_set_is_empty()

bk_bool unordered_set_is_empty ( unordered_set  me)

Determines whether or not the unordered set is empty.

Parameters
methe unordered set to check
Returns
BK_TRUE if the unordered set is empty, otherwise BK_FALSE

◆ unordered_set_put()

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.

Parameters
methe unordered set to add to
keythe element to add
Returns
BK_OK if no error
-BK_ENOMEM if out of memory

◆ unordered_set_rehash()

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.

Parameters
methe unordered set to rehash
Returns
BK_OK if no error
-BK_ENOMEM if out of memory

◆ unordered_set_remove()

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.

Parameters
methe unordered set to remove a key from
keythe key to remove
Returns
BK_TRUE if the unordered set contained the key, otherwise BK_FALSE

◆ unordered_set_size()

size_t unordered_set_size ( unordered_set  me)

Gets the size of the unordered set.

Parameters
methe unordered set to check
Returns
the size of the unordered set

◆ vector_add_all()

bk_err vector_add_all ( vector  me,
void *const  arr,
const size_t  size 
)

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.

Parameters
methe vector to add data to
arrthe array to copy data from
sizethe number of elements to copy
Returns
BK_OK if no error
-BK_ENOMEM if out of memory
-BK_ERANGE if size has reached representable limit

◆ vector_add_at()

bk_err vector_add_at ( vector  me,
const size_t  index,
void *const  data 
)

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.

Parameters
methe vector to add to
indexthe location in the vector to add the data to
datathe data to add to the vector
Returns
BK_OK if no error
-BK_ENOMEM if out of memory
-BK_EINVAL if invalid argument
-BK_ERANGE if size has reached representable limit

◆ vector_add_first()

bk_err vector_add_first ( vector  me,
void *const  data 
)

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.

Parameters
methe vector to add to
datathe data to add to the vector
Returns
BK_OK if no error
-BK_ENOMEM if out of memory
-BK_ERANGE if size has reached representable limit

◆ vector_add_last()

bk_err vector_add_last ( vector  me,
void *const  data 
)

Adds an element to the end of the vector.

Parameters
methe vector to add to
datathe data to add to the vector
Returns
BK_OK if no error
-BK_ENOMEM if out of memory
-BK_ERANGE if size has reached representable limit

◆ vector_capacity()

size_t vector_capacity ( vector  me)

Gets the capacity that the internal storage of the vector is using.

Parameters
methe vector to check
Returns
the capacity that the internal storage of the vector is using

◆ vector_clear()

bk_err vector_clear ( vector  me)

Clears the elements from the vector.

Parameters
methe vector to clear
Returns
BK_OK if no error
-BK_ENOMEM if out of memory

◆ vector_copy_to_array()

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.

Parameters
arrthe initialized array to copy the vector to
methe vector to copy to the array

◆ vector_destroy()

vector vector_destroy ( vector  me)

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.

Parameters
methe vector to free from memory
Returns
NULL

◆ vector_get_at()

bk_err vector_get_at ( void *const  data,
vector  me,
const size_t  index 
)

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.

Parameters
datathe data to copy to
methe vector to copy from
indexthe index to copy from in the vector
Returns
BK_OK if no error
-BK_EINVAL if invalid argument

◆ vector_get_data()

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.

Parameters
methe vector to get the storage element from
Returns
the storage element of the vector

◆ vector_get_first()

bk_err vector_get_first ( void *const  data,
vector  me 
)

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.

Parameters
datathe data to copy to
methe vector to copy from
Returns
BK_OK if no error
-BK_EINVAL if invalid argument

◆ vector_get_last()

bk_err vector_get_last ( void *const  data,
vector  me 
)

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.

Parameters
datathe data to copy to
methe vector to copy from
Returns
BK_OK if no error
-BK_EINVAL if invalid argument

◆ vector_init()

vector vector_init ( const size_t  data_size)

Initializes a vector.

Parameters
data_sizethe size of each element in the vector; must be positive
Returns
the newly-initialized vector, or NULL if it was not successfully initialized due to either invalid input arguments or memory allocation error

◆ vector_is_empty()

bk_bool vector_is_empty ( vector  me)

Determines whether or not the vector is empty.

Parameters
methe vector to check
Returns
BK_TRUE if the vector is empty, otherwise BK_FALSE

◆ vector_remove_at()

bk_err vector_remove_at ( vector  me,
const size_t  index 
)

Removes element based on its index.

Parameters
methe vector to remove from
indexthe location in the vector to remove the data from
Returns
BK_OK if no error
-BK_EINVAL if invalid argument

◆ vector_remove_first()

bk_err vector_remove_first ( vector  me)

Removes the first element from the vector.

Parameters
methe vector to remove from
Returns
BK_OK if no error
-BK_EINVAL if invalid argument

◆ vector_remove_last()

bk_err vector_remove_last ( vector  me)

Removes the last element from the vector.

Parameters
methe vector to remove from
Returns
BK_OK if no error
-BK_EINVAL if invalid argument

◆ vector_reserve()

bk_err vector_reserve ( vector  me,
size_t  size 
)

Reserves space specified. If more space than specified is already reserved, then the previous space will be kept.

Parameters
methe vector to reserve space for
sizethe space to reserve
Returns
BK_OK if no error
-BK_ENOMEM if out of memory
-BK_ERANGE if space to reserve exceeds representable limit

◆ vector_set_at()

bk_err vector_set_at ( vector  me,
const size_t  index,
void *const  data 
)

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.

Parameters
methe vector to set data for
indexthe location to set data at in the vector
datathe data to set at the location in the vector
Returns
BK_OK if no error
-BK_EINVAL if invalid argument

◆ vector_set_first()

bk_err vector_set_first ( vector  me,
void *const  data 
)

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.

Parameters
methe vector to set data for
datathe data to set at the start of the vector
Returns
BK_OK if no error
-BK_EINVAL if invalid argument

◆ vector_set_last()

bk_err vector_set_last ( vector  me,
void *const  data 
)

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.

Parameters
methe vector to set data for
datathe data to set at the end of the vector
Returns
BK_OK if no error
-BK_EINVAL if invalid argument

◆ vector_size()

size_t vector_size ( vector  me)

Gets the size being used by the vector.

Parameters
methe vector to check
Returns
the size being used by the vector

◆ vector_trim()

bk_err vector_trim ( vector  me)

Sets the size of the vector buffer to the current size being used.

Parameters
methe vector to trim
Returns
BK_OK if no error
-BK_ENOMEM if out of memory