Single linked list. Each list must have a head (struct sl_list_head_t) that is initiliazed with sl_list_init() function. List items must contain struct sl_list_t as its first member.
Example:
list_head_t head;
struct my_item {
char my_data[MY_DATA_LEN];
};
struct my_item item;
void sl_list_push_back(sl_list_head_t *list_head, sl_list_t *element)
void sl_list_init(sl_list_head_t *list_head)
Single linked list allows fast adding to both back and front, and fast removing from front (see the table of operations and their execution time below). Thus, FIFO list should be implemented by pushing to back and popping from front.
Operation | Time
-----------+--------
push back | O(1)
push front | O(1)
pop | O(n)
pop front | O(1)
pop back | O(n)
size | O(1)
at | O(n)
search | O(n)
Definition in file sl_list.h.
|
void | sl_list_init (sl_list_head_t *list_head) |
|
sl_list_t * | sl_list_next (const sl_list_t *iter) |
|
void | sl_list_push_before (sl_list_head_t *list_head, const sl_list_t *iter, sl_list_t *element) |
|
void | sl_list_push_back (sl_list_head_t *list_head, sl_list_t *element) |
|
void | sl_list_push_front (sl_list_head_t *list_head, sl_list_t *element) |
|
sl_list_t * | sl_list_pop_front (sl_list_head_t *list_head) |
|
sl_list_t * | sl_list_pop_back (sl_list_head_t *list_head) |
|
sl_list_t * | sl_list_pop (sl_list_head_t *list_head, sl_list_t *element) |
|
sl_list_t * | sl_list_remove (sl_list_head_t *list_head, sl_list_t *element) |
|
sl_list_t * | sl_list_at (const sl_list_head_t *list_head, int idx) |
|
unsigned char | sl_list_contains (const sl_list_head_t *list_head, const sl_list_t *element) |
|
sl_list_t * | sl_list_search (const sl_list_t *start, int(*match)(const sl_list_t *, const void *), const void *match_param) |
|
void | sl_list_swap (sl_list_head_t *list1, sl_list_head_t *list2) |
|