Defines functions and structs for double linked list. More...
#include <stdlib.h>
#include <string.h>
#include <assert.h>
Go to the source code of this file.
Data Structures | |
struct | CMimeListElem_T |
An element of a CMimeList_T list. More... | |
struct | CMimeList_T |
Double linked list implementation. More... | |
Macros | |
#define | cmime_list_size(list) ((list)->size) |
#define | cmime_list_head(list) ((list)->head) |
#define | cmime_list_tail(list) ((list)->tail) |
#define | cmime_list_is_head(elem) ((elem)->prev == NULL ? 1 : 0) |
#define | cmime_list_is_tail(elem) ((elem)->next == NULL ? 1 : 0) |
#define | cmime_list_data(elem) ((elem)->data) |
#define | cmime_list_next(elem) ((elem)->next) |
#define | cmime_list_prev(elem) ((elem)->prev) |
Functions | |
int | cmime_list_new (CMimeList_T **list, void(*destroy)(void *data)) |
Creates a new CMimeList_T list. More... | |
int | cmime_list_free (CMimeList_T *list) |
Free a CMimeList_T list. More... | |
int | cmime_list_remove (CMimeList_T *list, CMimeListElem_T *elem, void **data) |
Remove an element from list. More... | |
int | cmime_list_append (CMimeList_T *list, void *data) |
Append data to the end of a list. More... | |
int | cmime_list_prepend (CMimeList_T *list, void *data) |
Prepend data to a list. More... | |
void * | cmime_list_pop_tail (CMimeList_T *list) |
Remove tail element from list and return data pointer. More... | |
void * | cmime_list_pop_head (CMimeList_T *list) |
Remove head element from list an return data pointer. More... | |
int | cmime_list_insert_next (CMimeList_T *list, CMimeListElem_T *elem, void *data) |
Insert new element next to elem. More... | |
int | cmime_list_insert_prev (CMimeList_T *list, CMimeListElem_T *elem, void *data) |
Insert new element previous to elem. More... | |
void | cmime_list_map (CMimeList_T *list, void(*func)(CMimeListElem_T *elem, void *args), void *args) |
Iterates over list and calls function for every element with the current element. More... | |
int | cmime_list_map_new (CMimeList_T *list, CMimeList_T **new_list, void *(*func)(CMimeListElem_T *elem, void *args), void *args) |
Iterates over list and calls function func with every element, return value of func will be saved in new list **new_list. More... | |
Defines functions and structs for double linked list.
#define cmime_list_data | ( | elem | ) | ((elem)->data) |
#define cmime_list_head | ( | list | ) | ((list)->head) |
#define cmime_list_is_head | ( | elem | ) | ((elem)->prev == NULL ? 1 : 0) |
#define cmime_list_is_tail | ( | elem | ) | ((elem)->next == NULL ? 1 : 0) |
#define cmime_list_next | ( | elem | ) | ((elem)->next) |
#define cmime_list_prev | ( | elem | ) | ((elem)->prev) |
#define cmime_list_size | ( | list | ) | ((list)->size) |
#define cmime_list_tail | ( | list | ) | ((list)->tail) |
int cmime_list_append | ( | CMimeList_T * | list, |
void * | data | ||
) |
Append data to the end of a list.
list | CMimeList_T list to which new data should be appended |
data | new data which should be appended |
int cmime_list_free | ( | CMimeList_T * | list | ) |
int cmime_list_insert_next | ( | CMimeList_T * | list, |
CMimeListElem_T * | elem, | ||
void * | data | ||
) |
Insert new element next to elem.
list | a CMimeList_T list |
elem | a CMimeListElem_T element |
data | data to insert next to element |
int cmime_list_insert_prev | ( | CMimeList_T * | list, |
CMimeListElem_T * | elem, | ||
void * | data | ||
) |
Insert new element previous to elem.
list | a CMimeList_T list |
elem | a CMimeListElem_T element |
data | data to insert previous to element |
void cmime_list_map | ( | CMimeList_T * | list, |
void(*)(CMimeListElem_T *elem, void *args) | func, | ||
void * | args | ||
) |
Iterates over list and calls function for every element with the current element.
list | a CMimeList_T list |
func | function to call for each element |
args | optional arguments for function pointer |
int cmime_list_map_new | ( | CMimeList_T * | list, |
CMimeList_T ** | new_list, | ||
void *(*)(CMimeListElem_T *elem, void *args) | func, | ||
void * | args | ||
) |
Iterates over list and calls function func with every element, return value of func will be saved in new list **new_list.
list | a CMimeList_T list |
new_list | out param to return the new list |
func | function to call for each element |
args | optional arguments for function pointer |
int cmime_list_new | ( | CMimeList_T ** | list, |
void(*)(void *data) | destroy | ||
) |
Creates a new CMimeList_T list.
list | out param to return the new list |
func | list destroy function |
void* cmime_list_pop_head | ( | CMimeList_T * | list | ) |
Remove head element from list an return data pointer.
list | a CMimeList_T list |
void* cmime_list_pop_tail | ( | CMimeList_T * | list | ) |
Remove tail element from list and return data pointer.
list | a CMimeList_T list |
int cmime_list_prepend | ( | CMimeList_T * | list, |
void * | data | ||
) |
Prepend data to a list.
list | a CMimeList_T list to which new data should be prepended |
data | new data which should be appended |
int cmime_list_remove | ( | CMimeList_T * | list, |
CMimeListElem_T * | elem, | ||
void ** | data | ||
) |
Remove an element from list.
list | a CMimeList_T list |
elem | the CMimeListElem_T element which should be removed |
data | out param to return element data |