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.
forward_list.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2017-2020 Bailey Thompson
3  *
4  * Permission is hereby granted, free of charge, to any person obtaining a copy
5  * of this software and associated documentation files (the "Software"), to deal
6  * in the Software without restriction, including without limitation the rights
7  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8  * copies of the Software, and to permit persons to whom the Software is
9  * furnished to do so, subject to the following conditions:
10  *
11  * The above copyright notice and this permission notice shall be included in
12  * all copies or substantial portions of the Software.
13  *
14  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20  * SOFTWARE.
21  */
22 
23 #ifndef BKTHOMPS_CONTAINERS_FORWARD_LIST_H
24 #define BKTHOMPS_CONTAINERS_FORWARD_LIST_H
25 
26 #include "_bk_defines.h"
27 
31 typedef struct internal_forward_list *forward_list;
32 
33 /* Starting */
34 forward_list forward_list_init(size_t data_size);
35 
36 /* Utility */
39 void forward_list_copy_to_array(void *arr, forward_list me);
40 bk_err forward_list_add_all(forward_list me, void *arr, size_t size);
41 
42 /* Adding */
44 bk_err forward_list_add_at(forward_list me, size_t index, void *data);
46 
47 /* Removing */
51 
52 /* Setting */
54 bk_err forward_list_set_at(forward_list me, size_t index, void *data);
56 
57 /* Getting */
59 bk_err forward_list_get_at(void *data, forward_list me, size_t index);
61 
62 /* Ending */
65 
66 #endif /* BKTHOMPS_CONTAINERS_FORWARD_LIST_H */
bk_err forward_list_set_last(forward_list me, void *data)
Definition: forward_list.c:401
bk_err forward_list_add_at(forward_list me, size_t index, void *data)
Definition: forward_list.c:232
bk_err forward_list_add_all(forward_list me, void *arr, size_t size)
Definition: forward_list.c:126
bk_bool forward_list_is_empty(forward_list me)
Definition: forward_list.c:85
bk_err forward_list_set_at(forward_list me, size_t index, void *data)
Definition: forward_list.c:376
struct internal_forward_list * forward_list
Definition: forward_list.h:31
bk_err forward_list_set_first(forward_list me, void *data)
Definition: forward_list.c:357
forward_list forward_list_destroy(forward_list me)
Definition: forward_list.c:498
bk_err forward_list_remove_at(forward_list me, size_t index)
Definition: forward_list.c:302
size_t forward_list_size(forward_list me)
Definition: forward_list.c:73
void forward_list_copy_to_array(void *arr, forward_list me)
Definition: forward_list.c:101
forward_list forward_list_init(size_t data_size)
Definition: forward_list.c:46
bk_err forward_list_get_at(void *data, forward_list me, size_t index)
Definition: forward_list.c:440
void forward_list_clear(forward_list me)
Definition: forward_list.c:476
int bk_bool
Definition: containers.h:49
int bk_err
Definition: containers.h:48
bk_err forward_list_add_first(forward_list me, void *data)
Definition: forward_list.c:212
bk_err forward_list_remove_first(forward_list me)
Definition: forward_list.c:288
bk_err forward_list_add_last(forward_list me, void *data)
Definition: forward_list.c:275
struct internal_forward_list * forward_list
Definition: containers.h:130
bk_err forward_list_get_first(void *data, forward_list me)
Definition: forward_list.c:420
bk_err forward_list_get_last(void *data, forward_list me)
Definition: forward_list.c:466
bk_err forward_list_remove_last(forward_list me)
Definition: forward_list.c:339