Lines Matching refs:list

330 #define SGLIB_LIST_ADD(type, list, elem, next) {\
331 (elem)->next = (list);\
332 (list) = (elem);\
345 #define SGLIB_LIST_DELETE(type, list, elem, next) {\
347 for(_p_ = &(list); *_p_!=NULL && *_p_!=(elem); _p_= &(*_p_)->next) ;\
352 #define SGLIB_LIST_ADD_IF_NOT_MEMBER(type, list, elem, comparator, next, member) {\
354 for(_p_ = (list); _p_!=NULL && comparator(_p_, (elem)) != 0; _p_= _p_->next) ;\
357 SGLIB_LIST_ADD(type, list, elem, next);\
361 #define SGLIB_LIST_DELETE_IF_MEMBER(type, list, elem, comparator, next, member) {\
363 for(_p_ = &(list); *_p_!=NULL && comparator((*_p_), (elem)) != 0; _p_= &(*_p_)->next) ;\
370 #define SGLIB_LIST_IS_MEMBER(type, list, elem, next, result) {\
372 for(_p_ = (list); _p_!=NULL && _p_ != (elem); _p_= _p_->next) ;\
376 #define SGLIB_LIST_FIND_MEMBER(type, list, elem, comparator, next, member) {\
378 for(_p_ = (list); _p_!=NULL && comparator(_p_, (elem)) != 0; _p_= _p_->next) ;\
382 #define SGLIB_LIST_MAP_ON_ELEMENTS(type, list, iteratedVariable, next, command) {\
385 (iteratedVariable) = (list);\
393 #define SGLIB_LIST_LEN(type, list, next, result) {\
397 SGLIB_LIST_MAP_ON_ELEMENTS(type, list, _ce_, next, (result)++);\
400 #define SGLIB_LIST_REVERSE(type, list, next) {\
402 _list_ = (list);\
408 (list) = _res_;\
411 #define SGLIB_LIST_SORT(type, list, comparator, next) {\
416 _r_ = (list);\
448 (list) = _r_;\
451 /* --------------------------------- sorted list (level 0) --------------------- */
453 All operations suppose that the list is sorted and they preserve
458 #define SGLIB_SORTED_LIST_ADD(type, list, elem, comparator, next) {\
461 SGLIB_SORTED_LIST_FIND_MEMBER_OR_PLACE(type, list, elem, comparator, next, _cmpres_, _e_);\
466 #define SGLIB_SORTED_LIST_ADD_IF_NOT_MEMBER(type, list, elem, comparator, next, member) {\
469 SGLIB_SORTED_LIST_FIND_MEMBER_OR_PLACE(type, list, elem, comparator, next, _cmp_res_, _e_);\
479 #define SGLIB_SORTED_LIST_DELETE(type, list, elem, next) {\
480 SGLIB_LIST_DELETE(type, list, elem, next);\
483 #define SGLIB_SORTED_LIST_DELETE_IF_MEMBER(type, list, elem, comparator, next, member) {\
486 SGLIB_SORTED_LIST_FIND_MEMBER_OR_PLACE(type, list, elem, comparator, next, _cmp_res_, _e_);\
495 #define SGLIB_SORTED_LIST_FIND_MEMBER(type, list, elem, comparator, next, member) {\
498 for(_p_ = (list); _p_!=NULL && (_cmpres_=comparator(_p_, (elem))) < 0; _p_=_p_->next) ;\
503 #define SGLIB_SORTED_LIST_IS_MEMBER(type, list, elem, comparator, next, result) {\
505 for(_p_ = (list); _p_!=NULL && comparator(_p_, (elem)) < 0; _p_=_p_->next) ;\
510 #define SGLIB_SORTED_LIST_FIND_MEMBER_OR_PLACE(type, list, elem, comparator, next, comparator_result, member_ptr) {\
512 for((member_ptr) = &(list);\
517 #define SGLIB_SORTED_LIST_LEN(type, list, next, result) {\
518 SGLIB_LIST_LEN(type, list, next, result);\
521 #define SGLIB_SORTED_LIST_MAP_ON_ELEMENTS(type, list, iteratedVariable, next, command) {\
522 SGLIB_LIST_MAP_ON_ELEMENTS(type, list, iteratedVariable, next, command);\
526 /* ------------------------------- double linked list (level 0) ------------------------- */
532 #define SGLIB___DL_LIST_CREATE_SINGLETON(type, list, elem, previous, next) {\
533 (list) = (elem);\
534 (list)->next = (list)->previous = NULL;\
559 #define SGLIB_DL_LIST_ADD(type, list, elem, previous, next) {\
560 SGLIB_DL_LIST_ADD_BEFORE(type, list, elem, previous, next)\
561 (list) = (elem);\
564 #define SGLIB___DL_LIST_GENERIC_ADD_IF_NOT_MEMBER(type, list, elem, comparator, previous, next, member, the_add_operation) {\
566 for(_dlp_ = (list); _dlp_!=NULL && comparator(_dlp_, (elem)) != 0; _dlp_= _dlp_->previous) ;\
567 if (_dlp_ == NULL && (list) != NULL) {\
568 for(_dlp_ = (list)->next; _dlp_!=NULL && comparator(_dlp_, (elem)) != 0; _dlp_= _dlp_->next) ;\
572 the_add_operation(type, list, elem, previous, next);\
576 #define SGLIB_DL_LIST_ADD_BEFORE_IF_NOT_MEMBER(type, list, elem, comparator, previous, next, member) {\
577 SGLIB___DL_LIST_GENERIC_ADD_IF_NOT_MEMBER(type, list, elem, comparator, previous, next, member, SGLIB_DL_LIST_ADD_BEFORE);\
580 #define SGLIB_DL_LIST_ADD_AFTER_IF_NOT_MEMBER(type, list, elem, comparator, previous, next, member) {\
581 SGLIB___DL_LIST_GENERIC_ADD_IF_NOT_MEMBER(type, list, elem, comparator, previous, next, member, SGLIB_DL_LIST_ADD_AFTER);\
584 #define SGLIB_DL_LIST_ADD_IF_NOT_MEMBER(type, list, elem, comparator, previous, next, member) {\
585 SGLIB___DL_LIST_GENERIC_ADD_IF_NOT_MEMBER(type, list, elem, comparator, previous, next, member, SGLIB_DL_LIST_ADD);\
598 #define SGLIB_DL_LIST_DELETE(type, list, elem, previous, next) {\
600 _l_ = (list);\
607 (list) = _l_;\
610 #define SGLIB_DL_LIST_DELETE_IF_MEMBER(type, list, elem, comparator, previous, next, member) {\
612 for(_dlp_ = (list); _dlp_!=NULL && comparator(_dlp_, (elem)) != 0; _dlp_= _dlp_->previous) ;\
613 if (_dlp_ == NULL && (list) != NULL) {\
614 for(_dlp_ = (list)->next; _dlp_!=NULL && comparator(_dlp_, (elem)) != 0; _dlp_= _dlp_->next) ;\
618 SGLIB_DL_LIST_DELETE(type, list, _dlp_, previous, next);\
622 #define SGLIB_DL_LIST_IS_MEMBER(type, list, elem, previous, next, result) {\
624 SGLIB_LIST_IS_MEMBER(type, list, elem, previous, result);\
625 if (result == 0 && (list) != NULL) {\
626 _dlp_ = (list)->next;\
631 #define SGLIB_DL_LIST_FIND_MEMBER(type, list, elem, comparator, previous, next, member) {\
633 SGLIB_LIST_FIND_MEMBER(type, list, elem, comparator, previous, member);\
634 if ((member) == NULL && (list) != NULL) {\
635 _dlp_ = (list)->next;\
640 #define SGLIB_DL_LIST_MAP_ON_ELEMENTS(type, list, iteratedVariable, previous, next, command) {\
644 if ((list)!=NULL) {\
645 _dl_ = (list)->next;\
646 SGLIB_LIST_MAP_ON_ELEMENTS(type, list, iteratedVariable, previous, command);\
651 #define SGLIB_DL_LIST_SORT(type, list, comparator, previous, next) {\
653 _dll_ = (list);\
658 (list) = _dll_;\
662 #define SGLIB_DL_LIST_GET_FIRST(type, list, previous, next, result) {\
664 _dll_ = (list);\
671 #define SGLIB_DL_LIST_GET_LAST(type, list, previous, next, result) {\
673 _dll_ = (list);\
680 #define SGLIB_DL_LIST_LEN(type, list, previous, next, result) {\
683 if ((list)==NULL) {\
686 SGLIB_LIST_LEN(type, list, previous, _r1_);\
687 _dl_ = (list)->next;\
693 #define SGLIB_DL_LIST_REVERSE(type, list, previous, next) {\
695 _list_ = (list);\
715 #define SGLIB___DL_LIST_CREATE_FROM_LIST(type, list, previous, next) {\
718 for(_dlt_ = (list); _dlt_!=NULL; _dlt_ = _dlt_->next) {\
1018 base container is simply a list or a sorted list, but it can be a
1117 /* ------------------------------------ list (level 1) -------------------------------- */
1126 extern void sglib_##type##_add(type **list, type *elem);\
1127 extern int sglib_##type##_add_if_not_member(type **list, type *elem, type **member);\
1129 extern void sglib_##type##_delete(type **list, type *elem);\
1130 extern int sglib_##type##_delete_if_member(type **list, type *elem, type **member);\
1131 extern int sglib_##type##_is_member(type *list, type *elem);\
1132 extern type *sglib_##type##_find_member(type *list, type *elem);\
1133 extern void sglib_##type##_sort(type **list);\
1134 extern int sglib_##type##_len(type *list);\
1135 extern void sglib_##type##_reverse(type **list);\
1136 extern type *sglib_##type##_it_init(struct sglib_##type##_iterator *it, type *list);\
1137 extern type *sglib_##type##_it_init_on_equal(struct sglib_##type##_iterator *it, type *list, int (*subcomparator)(type *, type *), type *equalto);\
1143 int sglib_##type##_is_member(type *list, type *elem) {\
1145 SGLIB_LIST_IS_MEMBER(type, list, elem, next, result);\
1148 type *sglib_##type##_find_member(type *list, type *elem) {\
1150 SGLIB_LIST_FIND_MEMBER(type, list, elem, comparator, next, result);\
1153 int sglib_##type##_add_if_not_member(type **list, type *elem, type **member) {\
1154 SGLIB_LIST_ADD_IF_NOT_MEMBER(type, *list, elem, comparator, next, *member);\
1157 void sglib_##type##_add(type **list, type *elem) {\
1158 SGLIB_LIST_ADD(type, *list, elem, next);\
1163 void sglib_##type##_delete(type **list, type *elem) {\
1164 SGLIB_LIST_DELETE(type, *list, elem, next);\
1166 int sglib_##type##_delete_if_member(type **list, type *elem, type **member) {\
1167 SGLIB_LIST_DELETE_IF_MEMBER(type, *list, elem, comparator, next, *member);\
1170 void sglib_##type##_sort(type **list) {\
1171 SGLIB_LIST_SORT(type, *list, comparator, next);\
1173 int sglib_##type##_len(type *list) {\
1175 SGLIB_LIST_LEN(type, list, next, res);\
1178 void sglib_##type##_reverse(type **list) {\
1179 SGLIB_LIST_REVERSE(type, *list, next);\
1182 type *sglib_##type##_it_init_on_equal(struct sglib_##type##_iterator *it, type *list, int (*subcomparator)(type *, type *), type *equalto) {\
1185 it->nextelem = list;\
1188 type *sglib_##type##_it_init(struct sglib_##type##_iterator *it, type *list) {\
1189 return(sglib_##type##_it_init_on_equal(it, list, NULL, NULL));\
1209 /* ----------------------------- sorted list (level 1) ----------------------------------- */
1219 extern void sglib_##type##_add(type **list, type *elem);\
1220 extern int sglib_##type##_add_if_not_member(type **list, type *elem, type **member);\
1221 extern void sglib_##type##_delete(type **list, type *elem);\
1222 extern int sglib_##type##_delete_if_member(type **list, type *elem, type **member);\
1223 extern int sglib_##type##_is_member(type *list, type *elem);\
1224 extern type *sglib_##type##_find_member(type *list, type *elem);\
1225 extern int sglib_##type##_len(type *list);\
1226 extern void sglib_##type##_sort(type **list);\
1227 extern type *sglib_##type##_it_init(struct sglib_##type##_iterator *it, type *list);\
1228 extern type *sglib_##type##_it_init_on_equal(struct sglib_##type##_iterator *it, type *list, int (*subcomparator)(type *, type *), type *equalto);\
1234 int sglib_##type##_is_member(type *list, type *elem) {\
1236 SGLIB_SORTED_LIST_IS_MEMBER(type, list, elem, comparator, next, result);\
1239 type *sglib_##type##_find_member(type *list, type *elem) {\
1241 SGLIB_SORTED_LIST_FIND_MEMBER(type, list, elem, comparator, next, result);\
1244 int sglib_##type##_add_if_not_member(type **list, type *elem, type **member) {\
1245 SGLIB_SORTED_LIST_ADD_IF_NOT_MEMBER(type, *list, elem, comparator, next, *member);\
1248 void sglib_##type##_add(type **list, type *elem) {\
1249 SGLIB_SORTED_LIST_ADD(type, *list, elem, comparator, next);\
1251 void sglib_##type##_delete(type **list, type *elem) {\
1252 SGLIB_SORTED_LIST_DELETE(type, *list, elem, next);\
1254 int sglib_##type##_delete_if_member(type **list, type *elem, type **member) {\
1255 SGLIB_SORTED_LIST_DELETE_IF_MEMBER(type, *list, elem, comparator, next, *member);\
1258 int sglib_##type##_len(type *list) {\
1260 SGLIB_SORTED_LIST_LEN(type, list, next, res);\
1263 void sglib_##type##_sort(type **list) {\
1264 SGLIB_LIST_SORT(type, *list, comparator, next);\
1267 type *sglib_##type##_it_init_on_equal(struct sglib_##type##_iterator *it, type *list, int (*subcomparator)(type *, type *), type *equalto) {\
1270 it->nextelem = list;\
1273 type *sglib_##type##_it_init(struct sglib_##type##_iterator *it, type *list) {\
1274 return(sglib_##type##_it_init_on_equal(it, list, NULL, NULL));\
1297 /* ----------------------------- double linked list (level 1) ------------------------------ */
1308 extern void sglib_##type##_add(type **list, type *elem);\
1309 extern void sglib_##type##_add_before(type **list, type *elem);\
1310 extern void sglib_##type##_add_after(type **list, type *elem);\
1311 extern int sglib_##type##_add_if_not_member(type **list, type *elem, type **member);\
1312 extern int sglib_##type##_add_before_if_not_member(type **list, type *elem, type **member);\
1313 extern int sglib_##type##_add_after_if_not_member(type **list, type *elem, type **member);\
1315 extern void sglib_##type##_delete(type **list, type *elem);\
1316 extern int sglib_##type##_delete_if_member(type **list, type *elem, type **member);\
1317 extern int sglib_##type##_is_member(type *list, type *elem);\
1318 extern type *sglib_##type##_find_member(type *list, type *elem);\
1319 extern type *sglib_##type##_get_first(type *list);\
1320 extern type *sglib_##type##_get_last(type *list);\
1321 extern void sglib_##type##_sort(type **list);\
1322 extern int sglib_##type##_len(type *list);\
1323 extern void sglib_##type##_reverse(type **list);\
1324 extern type *sglib_##type##_it_init(struct sglib_##type##_iterator *it, type *list);\
1325 extern type *sglib_##type##_it_init_on_equal(struct sglib_##type##_iterator *it, type *list, int (*subcomparator)(type *, type *), type *equalto);\
1331 void sglib_##type##_add(type **list, type *elem) {\
1332 SGLIB_DL_LIST_ADD(type, *list, elem, previous, next);\
1334 void sglib_##type##_add_after(type **list, type *elem) {\
1335 SGLIB_DL_LIST_ADD_AFTER(type, *list, elem, previous, next);\
1337 void sglib_##type##_add_before(type **list, type *elem) {\
1338 SGLIB_DL_LIST_ADD_BEFORE(type, *list, elem, previous, next);\
1340 int sglib_##type##_add_if_not_member(type **list, type *elem, type **member) {\
1341 SGLIB_DL_LIST_ADD_IF_NOT_MEMBER(type, *list, elem, comparator, previous, next, *member);\
1344 int sglib_##type##_add_after_if_not_member(type **list, type *elem, type **member) {\
1345 SGLIB_DL_LIST_ADD_AFTER_IF_NOT_MEMBER(type, *list, elem, comparator, previous, next, *member);\
1348 int sglib_##type##_add_before_if_not_member(type **list, type *elem, type **member) {\
1349 SGLIB_DL_LIST_ADD_BEFORE_IF_NOT_MEMBER(type, *list, elem, comparator, previous, next, *member);\
1355 void sglib_##type##_delete(type **list, type *elem) {\
1356 SGLIB_DL_LIST_DELETE(type, *list, elem, previous, next);\
1358 int sglib_##type##_delete_if_member(type **list, type *elem, type **member) {\
1359 SGLIB_DL_LIST_DELETE_IF_MEMBER(type, *list, elem, comparator, previous, next, *member);\
1362 int sglib_##type##_is_member(type *list, type *elem) {\
1364 SGLIB_DL_LIST_IS_MEMBER(type, list, elem, previous, next, result);\
1367 type *sglib_##type##_find_member(type *list, type *elem) {\
1369 SGLIB_DL_LIST_FIND_MEMBER(type, list, elem, comparator, previous, next, result);\
1372 type *sglib_##type##_get_first(type *list) {\
1374 SGLIB_DL_LIST_GET_FIRST(type, list, previous, next, result);\
1377 type *sglib_##type##_get_last(type *list) {\
1379 SGLIB_DL_LIST_GET_LAST(type, list, previous, next, result);\
1382 void sglib_##type##_sort(type **list) {\
1383 SGLIB_DL_LIST_SORT(type, *list, comparator, previous, next);\
1385 int sglib_##type##_len(type *list) {\
1387 SGLIB_DL_LIST_LEN(type, list, previous, next, res);\
1390 void sglib_##type##_reverse(type **list) {\
1391 SGLIB_DL_LIST_REVERSE(type, *list, previous, next);\
1394 type *sglib_##type##_it_init_on_equal(struct sglib_##type##_iterator *it, type *list, int (*subcomparator)(type *, type *), type *equalto) {\
1397 it->prevelem = list;\
1398 it->nextelem = list;\
1399 if (list != NULL) it->nextelem = list->next;\
1402 type *sglib_##type##_it_init(struct sglib_##type##_iterator *it, type *list) {\
1403 return(sglib_##type##_it_init_on_equal(it, list, NULL, NULL));\