Go to the documentation of this file. 35 #ifndef GWENHYWFAR_LIST2_H 36 #define GWENHYWFAR_LIST2_H 56 #define GWEN_LIST2_FUNCTION_LIB_DEFS(t, pr, decl) \ 57 typedef struct t##_LIST2 t##_LIST2; \ 58 typedef struct t##_LIST2_ITERATOR t##_LIST2_ITERATOR; \ 59 typedef t* (t##_LIST2_FOREACH)(t *element, void *user_data); \ 61 decl t##_LIST2 *pr##_List2_new(void); \ 62 decl void pr##_List2_free(t##_LIST2 *l); \ 63 decl t##_LIST2 *pr##_List2_dup(const t##_LIST2 *l); \ 64 decl void pr##_List2_Unshare(t##_LIST2 *l); \ 65 decl void pr##_List2_Dump(t##_LIST2 *l, FILE *f, unsigned int indent); \ 66 decl void pr##_List2_PushBack(t##_LIST2 *l, t *p); \ 67 decl void pr##_List2_PushFront(t##_LIST2 *l, t *p); \ 68 decl t *pr##_List2_GetFront(const t##_LIST2 *l); \ 69 decl t *pr##_List2_GetBack(const t##_LIST2 *l); \ 70 decl void pr##_List2_Erase(t##_LIST2 *l, t##_LIST2_ITERATOR *it); \ 71 decl void pr##_List2_Remove(t##_LIST2 *l, const t *p); \ 72 decl unsigned int pr##_List2_GetSize(const t##_LIST2 *l); \ 73 decl int pr##_List2_IsEmpty(const t##_LIST2 *l); \ 74 decl void pr##_List2_PopBack(t##_LIST2 *l); \ 75 decl void pr##_List2_PopFront(t##_LIST2 *l); \ 76 decl void pr##_List2_Clear(t##_LIST2 *l); \ 77 decl t##_LIST2_ITERATOR *pr##_List2_First(const t##_LIST2 *l); \ 78 decl t##_LIST2_ITERATOR *pr##_List2_Last(const t##_LIST2 *l); \ 79 decl t##_LIST2_ITERATOR *pr##_List2Iterator_new(t##_LIST2 *l); \ 80 decl void pr##_List2Iterator_free(t##_LIST2_ITERATOR *li); \ 81 decl t *pr##_List2Iterator_Previous(t##_LIST2_ITERATOR *li); \ 82 decl t *pr##_List2Iterator_Next(t##_LIST2_ITERATOR *li); \ 83 decl t *pr##_List2Iterator_Data(t##_LIST2_ITERATOR *li); \ 84 decl void pr##_List2Iterator_IncLinkCount(t##_LIST2_ITERATOR *li); \ 85 decl unsigned int pr##_List2Iterator_GetLinkCount(const t##_LIST2_ITERATOR *li); \ 86 decl t##_LIST2_ITERATOR *pr##_List2_FindIter(t##_LIST2 *l, const t *p); \ 87 decl const t *pr##_List2_Contains(t##_LIST2 *l, const t *p); \ 88 decl t *pr##_List2_ForEach(t##_LIST2 *l, t##_LIST2_FOREACH, void *user_data); 92 #define GWEN_LIST2_FUNCTION_DEFS(t, pr) \ 93 GWEN_LIST2_FUNCTION_LIB_DEFS(t, pr, GWEN_DUMMY_EMPTY_ARG) 99 #define GWEN_LIST2_FUNCTIONS(t, pr) \ 100 t##_LIST2 *pr##_List2_new(void) { \ 101 return (t##_LIST2*)GWEN_List_new(); \ 104 void pr##_List2_free(t##_LIST2 *l) { \ 105 GWEN_List_free((GWEN_LIST*)l); \ 108 t##_LIST2 *pr##_List2_dup(const t##_LIST2 *l) {\ 109 return (t##_LIST2*)GWEN_List_dup((const GWEN_LIST*)l); \ 112 void pr##_List2_Unshare(t##_LIST2 *l) { \ 113 GWEN_List_Unshare((GWEN_LIST*)l); \ 116 void pr##_List2_Dump(t##_LIST2 *l, FILE *f, unsigned int indent) { \ 117 GWEN_List_Dump((GWEN_LIST*) l, f, indent); \ 120 void pr##_List2_PushBack(t##_LIST2 *l, t *p) { \ 121 GWEN_List_PushBack((GWEN_LIST*) l, p); \ 124 void pr##_List2_PushFront(t##_LIST2 *l, t *p) { \ 125 GWEN_List_PushFront((GWEN_LIST*) l, p); \ 128 t *pr##_List2_GetFront(const t##_LIST2 *l) { \ 129 return (t*) GWEN_List_GetFront((const GWEN_LIST*) l); \ 132 t *pr##_List2_GetBack(const t##_LIST2 *l) { \ 133 return (t*) GWEN_List_GetBack((const GWEN_LIST*) l); \ 136 void pr##_List2_Erase(t##_LIST2 *l, t##_LIST2_ITERATOR *it) { \ 137 GWEN_List_Erase((GWEN_LIST*) l, (GWEN_LIST_ITERATOR*) it); \ 140 void pr##_List2_Remove(t##_LIST2 *l, const t *p){ \ 141 GWEN_List_Remove((GWEN_LIST*) l, p); \ 144 unsigned int pr##_List2_GetSize(const t##_LIST2 *l){ \ 145 return GWEN_List_GetSize((const GWEN_LIST*) l); \ 148 int pr##_List2_IsEmpty(const t##_LIST2 *l){ \ 149 return GWEN_List_IsEmpty((const GWEN_LIST*) l); \ 152 void pr##_List2_PopBack(t##_LIST2 *l){ \ 153 GWEN_List_PopBack((GWEN_LIST*) l); \ 156 void pr##_List2_PopFront(t##_LIST2 *l){ \ 157 GWEN_List_PopFront((GWEN_LIST*) l); \ 160 void pr##_List2_Clear(t##_LIST2 *l){ \ 161 GWEN_List_Clear((GWEN_LIST*) l); \ 165 t##_LIST2_ITERATOR *pr##_List2_First(const t##_LIST2 *l) { \ 166 return (t##_LIST2_ITERATOR*) GWEN_List_First((const GWEN_LIST*) l); \ 169 t##_LIST2_ITERATOR *pr##_List2_Last(const t##_LIST2 *l) { \ 170 return (t##_LIST2_ITERATOR*) GWEN_List_Last((const GWEN_LIST*) l); \ 173 t##_LIST2_ITERATOR *pr##_List2Iterator_new(t##_LIST2 *l) { \ 174 return (t##_LIST2_ITERATOR*) GWEN_ListIterator_new((GWEN_LIST*) l); \ 177 void pr##_List2Iterator_free(t##_LIST2_ITERATOR *li) {\ 178 GWEN_ListIterator_free((GWEN_LIST_ITERATOR*)li); \ 181 t *pr##_List2Iterator_Previous(t##_LIST2_ITERATOR *li) { \ 182 return (t*) GWEN_ListIterator_Previous((GWEN_LIST_ITERATOR*)li); \ 185 t *pr##_List2Iterator_Next(t##_LIST2_ITERATOR *li) { \ 186 return (t*) GWEN_ListIterator_Next((GWEN_LIST_ITERATOR*)li); \ 189 t *pr##_List2Iterator_Data(t##_LIST2_ITERATOR *li) { \ 190 return (t*) GWEN_ListIterator_Data((GWEN_LIST_ITERATOR*)li); \ 193 void pr##_List2Iterator_IncLinkCount(t##_LIST2_ITERATOR *li) { \ 194 GWEN_ListIterator_IncLinkCount((GWEN_LIST_ITERATOR*)li); \ 197 unsigned int pr##_List2Iterator_GetLinkCount(const t##_LIST2_ITERATOR *li){\ 198 return GWEN_ListIterator_GetLinkCount((const GWEN_LIST_ITERATOR*)li); \ 201 t##_LIST2_ITERATOR *pr##_List2_FindIter(t##_LIST2 *l, const t *p){ \ 202 return (t##_LIST2_ITERATOR*) GWEN_List_FindIter((GWEN_LIST *)l, p); \ 205 const t *pr##_List2_Contains(t##_LIST2 *l, const t *p){ \ 206 return (const t*) GWEN_List_Contains((GWEN_LIST*)l, p); \ 209 t *pr##_List2_ForEach(t##_LIST2 *l, t##_LIST2_FOREACH fn, void *user_data){ \ 210 t##_LIST2_ITERATOR *it; \ 214 it=pr##_List2_First(l); \ 217 el=pr##_List2Iterator_Data(it); \ 219 el=fn(el, user_data); \ 221 pr##_List2Iterator_free(it); \ 224 el=pr##_List2Iterator_Next(it); \ 226 pr##_List2Iterator_free(it); \ 234 #define GWEN_CONSTLIST2_FUNCTION_LIB_DEFS(t, pr, decl) \ 235 typedef struct t##_CONSTLIST2 t##_CONSTLIST2; \ 236 typedef struct t##_CONSTLIST2_ITERATOR t##_CONSTLIST2_ITERATOR; \ 237 typedef const t* (t##_CONSTLIST2_FOREACH)(const t *element, void *user_data); \ 239 decl t##_CONSTLIST2 *pr##_ConstList2_new(void); \ 240 decl void pr##_ConstList2_free(t##_CONSTLIST2 *l); \ 241 decl void pr##_ConstList2_PushBack(t##_CONSTLIST2 *l, const t *p); \ 242 decl void pr##_ConstList2_PushFront(t##_CONSTLIST2 *l, const t *p); \ 243 decl const t *pr##_ConstList2_GetFront(const t##_CONSTLIST2 *l); \ 244 decl const t *pr##_ConstList2_GetBack(const t##_CONSTLIST2 *l); \ 245 decl unsigned int pr##_ConstList2_GetSize(const t##_CONSTLIST2 *l); \ 246 decl int pr##_ConstList2_IsEmpty(const t##_CONSTLIST2 *l); \ 247 decl void pr##_ConstList2_PopBack(t##_CONSTLIST2 *l); \ 248 decl void pr##_ConstList2_PopFront(t##_CONSTLIST2 *l); \ 249 decl void pr##_ConstList2_Clear(t##_CONSTLIST2 *l); \ 250 decl t##_CONSTLIST2_ITERATOR *pr##_ConstList2_First(const t##_CONSTLIST2 *l); \ 251 decl t##_CONSTLIST2_ITERATOR *pr##_ConstList2_Last(const t##_CONSTLIST2 *l); \ 252 decl t##_CONSTLIST2_ITERATOR *pr##_ConstList2Iterator_new(t##_CONSTLIST2 *l); \ 253 decl void pr##_ConstList2Iterator_free(t##_CONSTLIST2_ITERATOR *li); \ 254 decl const t *pr##_ConstList2Iterator_Previous(t##_CONSTLIST2_ITERATOR *li); \ 255 decl const t *pr##_ConstList2Iterator_Next(t##_CONSTLIST2_ITERATOR *li); \ 256 decl const t *pr##_ConstList2Iterator_Data(t##_CONSTLIST2_ITERATOR *li); \ 257 decl t##_CONSTLIST2_ITERATOR *pr##_ConstList2_FindIter(t##_CONSTLIST2 *l, const t *p); \ 258 decl const t *pr##_ConstList2_Contains(t##_CONSTLIST2 *l, const t *p); \ 259 decl void pr##_ConstList2_Remove(t##_CONSTLIST2 *l, const t *p); \ 260 decl const t *pr##_ConstList2_ForEach(t##_CONSTLIST2 *l, t##_CONSTLIST2_FOREACH, void *user_data); 265 #define GWEN_CONSTLIST2_FUNCTION_DEFS(t, pr) \ 266 GWEN_CONSTLIST2_FUNCTION_LIB_DEFS(t, pr, GWEN_DUMMY_EMPTY_ARG) 269 #define GWEN_CONSTLIST2_FUNCTIONS(t, pr) \ 270 t##_CONSTLIST2 *pr##_ConstList2_new(void) { \ 271 return (t##_CONSTLIST2*)GWEN_ConstList_new(); \ 274 void pr##_ConstList2_free(t##_CONSTLIST2 *l) { \ 275 GWEN_ConstList_free((GWEN_CONSTLIST*)l); \ 278 void pr##_ConstList2_PushBack(t##_CONSTLIST2 *l, const t *p) { \ 279 GWEN_ConstList_PushBack((GWEN_CONSTLIST*) l, p); \ 282 void pr##_ConstList2_PushFront(t##_CONSTLIST2 *l, const t *p) { \ 283 GWEN_ConstList_PushFront((GWEN_CONSTLIST*) l, p); \ 286 const t *pr##_ConstList2_GetFront(const t##_CONSTLIST2 *l) { \ 287 return (t*) GWEN_ConstList_GetFront((const GWEN_CONSTLIST*) l); \ 290 const t *pr##_ConstList2_GetBack(const t##_CONSTLIST2 *l) { \ 291 return (t*) GWEN_ConstList_GetBack((const GWEN_CONSTLIST*) l); \ 295 unsigned int pr##_ConstList2_GetSize(const t##_CONSTLIST2 *l){ \ 296 return GWEN_ConstList_GetSize((const GWEN_CONSTLIST*) l); \ 299 int pr##_ConstList2_IsEmpty(const t##_CONSTLIST2 *l){ \ 300 return GWEN_ConstList_IsEmpty((const GWEN_CONSTLIST*) l); \ 303 void pr##_ConstList2_PopBack(t##_CONSTLIST2 *l){ \ 304 GWEN_ConstList_PopBack((GWEN_CONSTLIST*) l); \ 307 void pr##_ConstList2_PopFront(t##_CONSTLIST2 *l){ \ 308 GWEN_ConstList_PopFront((GWEN_CONSTLIST*) l); \ 311 void pr##_ConstList2_Clear(t##_CONSTLIST2 *l){ \ 312 GWEN_ConstList_Clear((GWEN_CONSTLIST*) l); \ 316 t##_CONSTLIST2_ITERATOR *pr##_ConstList2_First(const t##_CONSTLIST2 *l) { \ 317 return (t##_CONSTLIST2_ITERATOR*) GWEN_ConstList_First((const GWEN_CONSTLIST*) l); \ 320 t##_CONSTLIST2_ITERATOR *pr##_ConstList2_Last(const t##_CONSTLIST2 *l) { \ 321 return (t##_CONSTLIST2_ITERATOR*) GWEN_ConstList_Last((const GWEN_CONSTLIST*) l); \ 324 t##_CONSTLIST2_ITERATOR *pr##_ConstList2Iterator_new(t##_CONSTLIST2 *l) { \ 325 return (t##_CONSTLIST2_ITERATOR*) GWEN_ConstListIterator_new((GWEN_CONSTLIST*) l); \ 328 void pr##_ConstList2Iterator_free(t##_CONSTLIST2_ITERATOR *li) {\ 329 GWEN_ConstListIterator_free((GWEN_CONSTLIST_ITERATOR*)li); \ 332 const t *pr##_ConstList2Iterator_Previous(t##_CONSTLIST2_ITERATOR *li) { \ 333 return (t*) GWEN_ConstListIterator_Previous((GWEN_CONSTLIST_ITERATOR*)li); \ 336 const t *pr##_ConstList2Iterator_Next(t##_CONSTLIST2_ITERATOR *li) { \ 337 return (t*) GWEN_ConstListIterator_Next((GWEN_CONSTLIST_ITERATOR*)li); \ 340 const t *pr##_ConstList2Iterator_Data(t##_CONSTLIST2_ITERATOR *li) { \ 341 return (t*) GWEN_ConstListIterator_Data((GWEN_CONSTLIST_ITERATOR*)li); \ 344 t##_CONSTLIST2_ITERATOR *pr##_ConstList2_FindIter(t##_CONSTLIST2 *l, const t *p){ \ 345 return (t##_CONSTLIST2_ITERATOR*) GWEN_ConstList_FindIter((GWEN_CONSTLIST *)l, p); \ 348 const t *pr##_ConstList2_Contains(t##_CONSTLIST2 *l, const t *p){ \ 349 return (const t*) GWEN_ConstList_Contains((GWEN_CONSTLIST*)l, p); \ 352 void pr##_ConstList2_Remove(t##_CONSTLIST2 *l, const t *p){ \ 353 GWEN_ConstList_Remove((GWEN_CONSTLIST*) l, p); \ 356 const t *pr##_ConstList2_ForEach(t##_CONSTLIST2 *l, t##_CONSTLIST2_FOREACH fn, void *user_data){ \ 357 t##_CONSTLIST2_ITERATOR *it; \ 361 it=pr##_ConstList2_First(l); \ 364 el=pr##_ConstList2Iterator_Data(it); \ 366 el=fn(el, user_data); \ 368 pr##_ConstList2Iterator_free(it); \ 371 el=pr##_ConstList2Iterator_Next(it); \ 373 pr##_ConstList2Iterator_free(it); \