43 #define KSI_LIST(type) type##List 50 #define KSI_NEW_LIST(type, list) KSI_List_new(type##_free, (list)) 57 #define KSI_NEW_REFLIST(type, list) KSI_RefList_new(type##_free, type##_ref, (list)) 64 #define KSI_LIST_FN_NAME(type, name) type##List_##name 66 #define KSI_DEFINE_LIST_STRUCT(ltype, rtype) \ 74 int (*append)(ltype *, rtype *); \ 84 int (*removeElement)(ltype *, size_t, rtype **); \ 91 int (*indexOf)(ltype *, rtype *, size_t **); \ 101 int (*insertAt)(ltype *, size_t, rtype *); \ 111 int (*replaceAt)(ltype *, size_t, rtype *); \ 120 int (*elementAt)(ltype *, size_t pos, rtype **); \ 125 size_t (*length)(ltype *list); \ 126 void (*obj_free)(rtype *); \ 131 int (*sort)(ltype *list, int (*cmp)(const rtype **, const rtype **)); \ 138 int (*foldl)(ltype *list, void *foldCtx, int (*fn)(rtype *el, void *foldCtx)); \ 146 #define KSI_DEFINE_LIST(type) \ 147 typedef struct type##_list_st KSI_LIST(type); \ 148 struct type##_list_st { \ 149 KSI_DEFINE_LIST_STRUCT(KSI_LIST(type), type) \ 151 int KSI_LIST_FN_NAME(type, new)(KSI_LIST(type) **list); \ 152 void KSI_LIST_FN_NAME(type, free)(KSI_LIST(type) *list); \ 172 #define KSI_IMPLEMENT_LIST(type, free_fn) \ 173 int KSI_LIST_FN_NAME(type, new)(KSI_LIST(type) **list) { \ 174 return KSI_List_new((void (*)(void *))free_fn, (KSI_List **)list); \ 176 void KSI_LIST_FN_NAME(type, free)(KSI_LIST(type) *list) { \ 177 KSI_List_free((KSI_List *)list); \ void KSI_List_free(KSI_List *list)
int KSI_List_indexOf(KSI_List *list, void *o, size_t **i)
int KSI_List_foldl(KSI_List *list, void *foldCtx, int(*fn)(void *el, void *foldCtx))
int KSI_List_remove(KSI_List *list, size_t pos, void **o)
int KSI_List_elementAt(KSI_List *list, size_t pos, void **o)
size_t KSI_List_length(KSI_List *list)
int KSI_List_new(void(*obj_free)(void *), KSI_List **list)
int KSI_List_insertAt(KSI_List *list, size_t pos, void *o)
int KSI_List_sort(KSI_List *list, int(*)(const void **, const void **))
int KSI_List_append(KSI_List *list, void *o)
int KSI_List_replaceAt(KSI_List *list, size_t pos, void *o)
struct KSI_List_st KSI_List
Definition: list.h:37