133#error Must define a SPECLIST_TAG to use this header
137#define SPECLIST_TYPE struct SPECLIST_TAG
140#define SPECLIST_PASTE_(x, y) x ## y
141#define SPECLIST_PASTE(x, y) SPECLIST_PASTE_(x,y)
143#define SPECLIST_LIST struct SPECLIST_PASTE(SPECLIST_TAG, _list)
144#define SPECLIST_LINK struct SPECLIST_PASTE(SPECLIST_TAG, _list_link)
145#define SPECLIST_FOO(suffix) SPECLIST_PASTE(SPECLIST_TAG, suffix)
474 (
int (*)(
const void *,
const void *))
compar);
549#undef SPECLIST_PASTE_
555#ifndef FC__SPECLIST_H
556#define FC__SPECLIST_H
559# define TYPED_LIST_CHECK(ARG_list) \
560 fc_assert_action(NULL != ARG_list, break)
562# define TYPED_LIST_CHECK(ARG_list)
575#define TYPED_LIST_ITERATE(TYPE_data, ARG_list, NAME_data) \
577 const struct genlist_link *NAME_data##_iter; \
578 TYPE_data *NAME_data; \
579 TYPED_LIST_CHECK(ARG_list); \
580 NAME_data##_iter = genlist_head((const struct genlist *) ARG_list); \
581 while (NULL != NAME_data##_iter) { \
582 NAME_data = (TYPE_data *) genlist_link_data(NAME_data##_iter); \
583 NAME_data##_iter = genlist_link_next(NAME_data##_iter);
586#define LIST_ITERATE_END \
601#define MUTEXED_LIST_ITERATE(TYPE_data, LIST_tag, ARG_list, NAME_data) \
603 const struct genlist_link *NAME_data##_iter; \
604 TYPE_data *NAME_data; \
605 LIST_tag##_list_allocate_mutex(ARG_list); \
606 TYPED_LIST_CHECK(ARG_list); \
607 NAME_data##_iter = genlist_head((const struct genlist *) ARG_list); \
608 while (NULL != NAME_data##_iter) { \
609 NAME_data = (TYPE_data *) genlist_link_data(NAME_data##_iter); \
610 NAME_data##_iter = genlist_link_next(NAME_data##_iter);
613#define MUTEXED_ITERATE_END(LIST_tag, ARG_list) \
615 LIST_tag##_list_release_mutex(ARG_list); \
618#define MUTEXED_ITERATE_BREAK(LIST_tag, ARG_list) \
620 LIST_tag##_list_release_mutex(ARG_list); \
628#define TYPED_LIST_ITERATE_REV(TYPE_data, ARG_list, NAME_data) \
630 const struct genlist_link *NAME_data##_iter; \
631 TYPE_data *NAME_data; \
632 TYPED_LIST_CHECK(ARG_list); \
633 NAME_data##_iter = genlist_tail((const struct genlist *) ARG_list); \
634 while (NULL != NAME_data##_iter) { \
635 NAME_data = (TYPE_data *) genlist_link_data(NAME_data##_iter); \
636 NAME_data##_iter = genlist_link_prev(NAME_data##_iter);
639#define LIST_ITERATE_REV_END \
651#define TYPED_LIST_LINK_ITERATE(TYPE_link, ARG_list, NAME_link) \
653 TYPE_link *NAME_link = ((TYPE_link *) \
654 genlist_head((const struct genlist *) ARG_list)); \
655 TYPE_link *NAME_link##_next; \
656 TYPED_LIST_CHECK(ARG_list); \
657 for (; NULL != NAME_link; NAME_link = NAME_link##_next) { \
658 NAME_link##_next = ((TYPE_link *) \
659 genlist_link_next((struct genlist_link *) \
663#define LIST_LINK_ITERATE_END \
672#define TYPED_LIST_LINK_ITERATE_REV(TYPE_link, ARG_list, NAME_link) \
674 TYPE_link *NAME_link = ((TYPE_link *) \
675 genlist_tail((const struct genlist *) ARG_list)); \
676 TYPE_link *NAME_link##_prev; \
677 TYPED_LIST_CHECK(ARG_list); \
678 for (; NULL != NAME_link; NAME_link = NAME_link##_prev) { \
679 NAME_link##_prev = ((TYPE_link *) \
680 genlist_link_prev((struct genlist_link *) \
684#define LIST_LINK_ITERATE_REV_END \
698#define TYPED_LIST_BOTH_ITERATE(TYPE_link, TYPE_data, \
699 ARG_list, NAME_link, NAME_data) \
701 TYPE_link *NAME_link = ((TYPE_link *) \
702 genlist_head((const struct genlist *) ARG_list)); \
703 TYPE_link *NAME_link##_next; \
704 TYPE_data *NAME_data; \
705 TYPED_LIST_CHECK(ARG_list); \
706 for (; NULL != NAME_link; NAME_link = NAME_link##_next) { \
707 NAME_link##_next = ((TYPE_link *) \
708 genlist_link_next((struct genlist_link *) \
710 NAME_data = ((TYPE_data *) \
711 genlist_link_data((struct genlist_link *) NAME_link));
714#define LIST_BOTH_ITERATE_END \
725#define TYPED_LIST_BOTH_ITERATE_REV(TYPE_link, TYPE_data, \
726 ARG_list, NAME_link, NAME_data) \
728 TYPE_link *NAME_link = ((TYPE_link *) \
729 genlist_tail((const struct genlist *) ARG_list)); \
730 TYPE_link *NAME_link##_prev; \
731 TYPE_data *NAME_data; \
732 TYPED_LIST_CHECK(ARG_list); \
733 for (; NULL != NAME_link; NAME_link = NAME_link##_prev) { \
734 NAME_link##_prev = ((TYPE_link *) \
735 genlist_link_prev((struct genlist_link *) \
737 NAME_data = ((TYPE_data *) \
738 genlist_link_data((struct genlist_link *) NAME_link));
741#define LIST_BOTH_ITERATE_REV_END \
bool genlist_remove(struct genlist *pgenlist, const void *punlink)
void genlist_allocate_mutex(struct genlist *pgenlist)
void genlist_insert(struct genlist *pgenlist, void *data, int pos)
struct genlist * genlist_copy_full(const struct genlist *pgenlist, genlist_copy_fn_t copy_data_func, genlist_free_fn_t free_data_func)
void genlist_release_mutex(struct genlist *pgenlist)
struct genlist * genlist_new(void)
void * genlist_get(const struct genlist *pgenlist, int idx)
int genlist_remove_all(struct genlist *pgenlist, const void *punlink)
void genlist_erase(struct genlist *pgenlist, struct genlist_link *plink)
struct genlist_link * genlist_search_if(const struct genlist *pgenlist, genlist_cond_fn_t cond_data_func)
void genlist_clear(struct genlist *pgenlist)
void genlist_prepend(struct genlist *pgenlist, void *data)
bool genlist_remove_if(struct genlist *pgenlist, genlist_cond_fn_t cond_data_func)
void genlist_append(struct genlist *pgenlist, void *data)
void genlist_unique_full(struct genlist *pgenlist, genlist_comp_fn_t comp_data_func)
struct genlist * genlist_copy(const struct genlist *pgenlist)
void genlist_destroy(struct genlist *pgenlist)
void genlist_pop_front(struct genlist *pgenlist)
void genlist_insert_before(struct genlist *pgenlist, void *data, struct genlist_link *plink)
void * genlist_back(const struct genlist *pgenlist)
int genlist_remove_all_if(struct genlist *pgenlist, genlist_cond_fn_t cond_data_func)
void genlist_unique(struct genlist *pgenlist)
void genlist_insert_after(struct genlist *pgenlist, void *data, struct genlist_link *plink)
void genlist_sort(struct genlist *pgenlist, int(*compar)(const void *, const void *))
void genlist_reverse(struct genlist *pgenlist)
struct genlist_link * genlist_tail(const struct genlist *pgenlist)
void * genlist_front(const struct genlist *pgenlist)
struct genlist * genlist_new_full(genlist_free_fn_t free_data_func)
struct genlist_link * genlist_link_get(const struct genlist *pgenlist, int idx)
void genlist_pop_back(struct genlist *pgenlist)
struct genlist_link * genlist_search(const struct genlist *pgenlist, const void *data)
int genlist_size(const struct genlist *pgenlist)
void genlist_shuffle(struct genlist *pgenlist)
bool(* genlist_cond_fn_t)(const void *)
bool(* genlist_comp_fn_t)(const void *, const void *)
static struct genlist_link * genlist_head(const struct genlist *pgenlist)
static void * genlist_link_data(const struct genlist_link *plink)
void *(* genlist_copy_fn_t)(const void *)
void(* genlist_free_fn_t)(void *)
static fc__warn_unused_result struct genlist_link * genlist_link_prev(const struct genlist_link *plink)
static fc__warn_unused_result struct genlist_link * genlist_link_next(const struct genlist_link *plink)
static SPECLIST_LIST *SPECLIST_FOO() _list_copy(const SPECLIST_LIST *tthis) fc__warn_unused_result
static void SPECLIST_FOO() _list_sort(SPECLIST_LIST *tthis, int(*compar)(const SPECLIST_TYPE *const *, const SPECLIST_TYPE *const *))
static void SPECLIST_FOO() _list_append(SPECLIST_LIST *tthis, SPECLIST_TYPE *pfoo)
static SPECLIST_LINK *SPECLIST_FOO() _list_tail(const SPECLIST_LIST *tthis)
static SPECLIST_LINK *SPECLIST_FOO() _list_search_if(const SPECLIST_LIST *tthis, SPECLIST_FOO(_list_cond_fn_t) cond_data_func)
static int SPECLIST_FOO() _list_size(const SPECLIST_LIST *tthis)
static SPECLIST_TYPE *SPECLIST_FOO() _list_link_data(const SPECLIST_LINK *plink)
static SPECLIST_TYPE *SPECLIST_FOO() _list_front(const SPECLIST_LIST *tthis)
static SPECLIST_LINK *SPECLIST_FOO() _list_search(const SPECLIST_LIST *tthis, const SPECLIST_TYPE *pfoo)
static SPECLIST_LINK *SPECLIST_FOO() _list_head(const SPECLIST_LIST *tthis)
static void SPECLIST_FOO() _list_erase(SPECLIST_LIST *tthis, SPECLIST_LINK *plink)
static SPECLIST_TYPE *SPECLIST_FOO() _list_back(const SPECLIST_LIST *tthis)
static SPECLIST_LIST *SPECLIST_FOO() _list_copy_full(const SPECLIST_LIST *tthis, SPECLIST_FOO(_list_copy_fn_t) copy_data_func, SPECLIST_FOO(_list_free_fn_t) free_data_func) fc__warn_unused_result
static bool SPECLIST_FOO() _list_remove(SPECLIST_LIST *tthis, const SPECLIST_TYPE *pfoo)
static void SPECLIST_FOO() _list_prepend(SPECLIST_LIST *tthis, SPECLIST_TYPE *pfoo)
static void SPECLIST_FOO() _list_pop_front(SPECLIST_LIST *tthis)
static void SPECLIST_FOO() _list_pop_back(SPECLIST_LIST *tthis)
static SPECLIST_LIST *SPECLIST_FOO() _list_new(void) fc__warn_unused_result
static void SPECLIST_FOO() _list_insert_before(SPECLIST_LIST *tthis, SPECLIST_TYPE *pfoo, SPECLIST_LINK *plink)
static bool SPECLIST_FOO() _list_remove_if(SPECLIST_LIST *tthis, SPECLIST_FOO(_list_cond_fn_t) cond_data_func)
static SPECLIST_TYPE *SPECLIST_FOO() _list_get(const SPECLIST_LIST *tthis, int slindex)
static void SPECLIST_FOO() _list_clear(SPECLIST_LIST *tthis)
static void SPECLIST_FOO() _list_reverse(SPECLIST_LIST *tthis)
static SPECLIST_LINK *SPECLIST_FOO() _list_link_next(const SPECLIST_LINK *plink) fc__warn_unused_result
static void SPECLIST_FOO() _list_insert_after(SPECLIST_LIST *tthis, SPECLIST_TYPE *pfoo, SPECLIST_LINK *plink)
static void SPECLIST_FOO() _list_allocate_mutex(SPECLIST_LIST *tthis)
static void SPECLIST_FOO() _list_shuffle(SPECLIST_LIST *tthis)
static void SPECLIST_FOO() _list_insert(SPECLIST_LIST *tthis, SPECLIST_TYPE *pfoo, int idx)
static bool SPECLIST_FOO() _list_remove_all_if(SPECLIST_LIST *tthis, cond_data_func)
static SPECLIST_LINK *SPECLIST_FOO() _list_link_get(const SPECLIST_LIST *tthis, int slindex)
static void SPECLIST_FOO() _list_unique(SPECLIST_LIST *tthis)
static void SPECLIST_FOO() _list_release_mutex(SPECLIST_LIST *tthis)
static SPECLIST_LIST *SPECLIST_FOO() _list_new_full(SPECLIST_FOO(_list_free_fn_t) free_data_func) fc__warn_unused_result
static void SPECLIST_FOO() _list_unique_full(SPECLIST_LIST *tthis, SPECLIST_FOO(_list_comp_fn_t) comp_data_func)
static void SPECLIST_FOO() _list_destroy(SPECLIST_LIST *tthis)
static SPECLIST_LINK *SPECLIST_FOO() _list_link_prev(const SPECLIST_LINK *plink) fc__warn_unused_result
#define SPECLIST_FOO(suffix)
static int SPECLIST_FOO() _list_remove_all(SPECLIST_LIST *tthis, const SPECLIST_TYPE *pfoo)
#define fc__warn_unused_result