Go to the source code of this file.
|
typedef struct internal_list * | list |
|
|
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) |
|
◆ list
typedef struct internal_list* list |
The list data structure, which is a doubly-linked list.
◆ 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
-
me | the doubly-linked list to add data to |
arr | the array to copy data from |
size | the 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
-
me | the doubly-linked list to add data to |
index | the index to add the data at |
data | the data to add to the doubly-linked list |
- 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
-
me | the doubly-linked list to add data to |
data | the 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
-
me | the doubly-linked list to add data to |
data | the 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
-
me | the 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
-
arr | the initialized array to copy the doubly-linked list to |
me | the doubly-linked list to copy to the array |
◆ list_destroy()
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
-
me | the 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
-
data | the data to get |
me | the doubly-linked list to get data from |
index | the 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
-
data | the data to get |
me | the 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
-
data | the data to get |
me | the 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_size | the 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()
Determines if the doubly-linked list is empty.
- Parameters
-
me | the 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
-
me | the doubly-linked list to remove data from |
index | the index to remove from |
- Returns
- BK_OK if no error
-
-BK_EINVAL if invalid argument
◆ list_remove_first()
Removes the first piece of data from the doubly-linked list.
- Parameters
-
me | the doubly-linked list to remove data from |
- Returns
- BK_OK if no error
-
-BK_EINVAL if invalid argument
◆ list_remove_last()
Removes the last piece of data from the doubly-linked list.
- Parameters
-
me | the 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
-
me | the doubly-linked list to set data for |
index | the index to set data in the doubly-linked list |
data | the data to set in the doubly-linked list |
- 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
-
me | the doubly-linked list to set data for |
data | the 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
-
me | the doubly-linked list to set data for |
data | the 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
-
me | the doubly-linked list to check |
- Returns
- the number of elements