30
30
including this file would provide a struct definition for:
32
32
and prototypes for the following functions:
33
void foo_list_init(struct foo_list *This);
33
struct foolist *foo_list_new();
34
34
int foo_list_size(struct foo_list *This);
35
35
foo_t *foo_list_get(struct foo_list *This, int index);
36
void foo_list_insert(struct foo_list *This, foo_t *pfoo);
37
void foo_list_insert_back(struct foo_list *This, foo_t *pfoo);
36
void foo_list_prepend(struct foo_list *This, foo_t *pfoo);
37
void foo_list_append(struct foo_list *This, foo_t *pfoo);
38
38
void foo_list_unlink(struct foo_list *This, foo_t *pfoo);
39
39
void foo_list_unlink_all(struct foo_list *This);
40
bool foo_list_search(struct foo_list *this, foo_t *pfoo);
40
41
void foo_list_sort(struct foo_list *This,
41
42
int (*compar)(const void *, const void *));
73
75
#define SPECLIST_FOO(suffix) SPECLIST_PASTE(SPECLIST_TAG, suffix)
79
static inline void SPECLIST_FOO(_list_init) (SPECLIST_LIST *tthis)
81
genlist_init(&tthis->list);
84
static inline void SPECLIST_FOO(_list_insert) (SPECLIST_LIST *tthis, SPECLIST_TYPE *pfoo)
86
genlist_insert(&tthis->list, pfoo, 0);
81
static inline SPECLIST_LIST *SPECLIST_FOO(_list_new) (void)
83
SPECLIST_LIST *speclist = (SPECLIST_LIST *)fc_malloc(sizeof(*speclist));
85
speclist->list = genlist_new();
89
static inline SPECLIST_LIST *SPECLIST_FOO(_list_copy) (SPECLIST_LIST *plist)
91
SPECLIST_LIST *newlist = (SPECLIST_LIST *)fc_malloc(sizeof(*newlist));
93
newlist->list = genlist_copy(plist ? plist->list : NULL);
98
static inline void SPECLIST_FOO(_list_prepend) (SPECLIST_LIST *tthis, SPECLIST_TYPE *pfoo)
100
genlist_prepend(tthis->list, pfoo);
89
103
static inline void SPECLIST_FOO(_list_unlink) (SPECLIST_LIST *tthis, SPECLIST_TYPE *pfoo)
91
genlist_unlink(&tthis->list, pfoo);
105
genlist_unlink(tthis->list, pfoo);
94
108
static inline int SPECLIST_FOO(_list_size) (const SPECLIST_LIST *tthis)
96
return genlist_size(&tthis->list);
110
return genlist_size(tthis->list);
99
113
static inline SPECLIST_TYPE *SPECLIST_FOO(_list_get) (const SPECLIST_LIST *tthis, int index)
101
return genlist_get(&tthis->list, index);
115
return (SPECLIST_TYPE *)genlist_get(tthis->list, index);
104
static inline void SPECLIST_FOO(_list_insert_back) (SPECLIST_LIST *tthis, SPECLIST_TYPE *pfoo)
118
static inline void SPECLIST_FOO(_list_append) (SPECLIST_LIST *tthis, SPECLIST_TYPE *pfoo)
106
genlist_insert(&tthis->list, pfoo, -1);
120
genlist_append(tthis->list, pfoo);
109
123
static inline void SPECLIST_FOO(_list_unlink_all) (SPECLIST_LIST *tthis)
111
genlist_unlink_all(&tthis->list);
125
genlist_unlink_all(tthis->list);
128
static inline void SPECLIST_FOO(_list_free) (SPECLIST_LIST *tthis)
130
genlist_free(tthis->list);
134
/****************************************************************************
135
Return TRUE iff this element is in the list.
137
This is an O(n) operation. Hence, "search".
138
****************************************************************************/
139
static inline bool SPECLIST_FOO(_list_search) (SPECLIST_LIST *tthis,
140
const SPECLIST_TYPE *pfoo)
142
return genlist_search(tthis->list, pfoo);
114
145
static inline void SPECLIST_FOO(_list_sort) (SPECLIST_LIST * tthis, int (*compar) (const void *, const void *))
116
genlist_sort(&tthis->list, compar);
147
genlist_sort(tthis->list, compar);
119
150
#undef SPECLIST_TAG