Lines Matching full:next

38  * To use singly-linked lists, your structure must have a "next" pointer.
39 * To use doubly-linked lists, your structure must "prev" and "next" pointers.
45 * struct item *prev, *next;
84 * to dereference its prev/next pointers, and save/restore the real head.*/
89 #define UTLIST_NEXT(elt,list,next) ((char*)((list)->next)) argument
90 #define UTLIST_NEXTASGN(elt,list,to,next) { char **_alias = (char**)&((list)->next); *_alias=(char*… argument
98 #define UTLIST_NEXT(elt,list,next) ((elt)->next) argument
99 #define UTLIST_NEXTASGN(elt,list,to,next) ((elt)->next)=(to) argument
111 LL_SORT2(list, cmp, next)
113 #define LL_SORT2(list, cmp, next) \ argument
135 UTLIST_SV(_ls_q,list); _ls_q = UTLIST_NEXT(_ls_q,list,next); UTLIST_RS(list); \
142 UTLIST_NEXT(_ls_q,list,next); UTLIST_RS(list); _ls_qsize--; \
145 UTLIST_NEXT(_ls_p,list,next); UTLIST_RS(list); _ls_psize--; \
148 UTLIST_NEXT(_ls_p,list,next); UTLIST_RS(list); _ls_psize--; \
151 UTLIST_NEXT(_ls_q,list,next); UTLIST_RS(list); _ls_qsize--; \
154 UTLIST_SV(_ls_tail,list); UTLIST_NEXTASGN(_ls_tail,list,_ls_e,next); UTLIST_RS(list); \
163 UTLIST_SV(_ls_tail,list); UTLIST_NEXTASGN(_ls_tail,list,NULL,next); UTLIST_RS(list); \
175 DL_SORT2(list, cmp, prev, next)
177 #define DL_SORT2(list, cmp, prev, next) \ argument
199 UTLIST_SV(_ls_q,list); _ls_q = UTLIST_NEXT(_ls_q,list,next); UTLIST_RS(list); \
206 UTLIST_NEXT(_ls_q,list,next); UTLIST_RS(list); _ls_qsize--; \
209 UTLIST_NEXT(_ls_p,list,next); UTLIST_RS(list); _ls_psize--; \
212 UTLIST_NEXT(_ls_p,list,next); UTLIST_RS(list); _ls_psize--; \
215 UTLIST_NEXT(_ls_q,list,next); UTLIST_RS(list); _ls_qsize--; \
218 UTLIST_SV(_ls_tail,list); UTLIST_NEXTASGN(_ls_tail,list,_ls_e,next); UTLIST_RS(list); \
228 UTLIST_SV(_ls_tail,list); UTLIST_NEXTASGN(_ls_tail,list,NULL,next); UTLIST_RS(list); \
238 CDL_SORT2(list, cmp, prev, next)
240 #define CDL_SORT2(list, cmp, prev, next) \ argument
265 if (UTLIST_NEXT(_ls_q,list,next) == _ls_oldhead) { \
268 _ls_q = UTLIST_NEXT(_ls_q,list,next); \
277 UTLIST_NEXT(_ls_q,list,next); UTLIST_RS(list); _ls_qsize--; \
281 UTLIST_NEXT(_ls_p,list,next); UTLIST_RS(list); _ls_psize--; \
285 UTLIST_NEXT(_ls_p,list,next); UTLIST_RS(list); _ls_psize--; \
289 UTLIST_NEXT(_ls_q,list,next); UTLIST_RS(list); _ls_qsize--; \
293 UTLIST_SV(_ls_tail,list); UTLIST_NEXTASGN(_ls_tail,list,_ls_e,next); UTLIST_RS(list); \
304 UTLIST_SV(_ls_tail,list); UTLIST_NEXTASGN(_ls_tail,list,_tmp,next); UTLIST_RS(list); \
317 LL_PREPEND2(head,add,next)
319 #define LL_PREPEND2(head,add,next) \ argument
321 (add)->next = (head); \
326 LL_CONCAT2(head1,head2,next)
328 #define LL_CONCAT2(head1,head2,next) \ argument
333 while (_tmp->next) { _tmp = _tmp->next; } \
334 _tmp->next=(head2); \
341 LL_APPEND2(head,add,next)
343 #define LL_APPEND2(head,add,next) \ argument
346 (add)->next=NULL; \
349 while (_tmp->next) { _tmp = _tmp->next; } \
350 _tmp->next=(add); \
357 LL_INSERT_INORDER2(head,add,cmp,next)
359 #define LL_INSERT_INORDER2(head,add,cmp,next) \ argument
363 LL_LOWER_BOUND2(head, _tmp, add, cmp, next); \
364 LL_APPEND_ELEM2(head, _tmp, add, next); \
367 (head)->next = NULL; \
372 LL_LOWER_BOUND2(head,elt,like,cmp,next)
374 #define LL_LOWER_BOUND2(head,elt,like,cmp,next) \ argument
379 for ((elt) = (head); (elt)->next != NULL; (elt) = (elt)->next) { \
380 if (cmp((elt)->next, like) >= 0) { \
388 LL_DELETE2(head,del,next)
390 #define LL_DELETE2(head,del,next) \ argument
394 (head)=(head)->next; \
397 while (_tmp->next && (_tmp->next != (del))) { \
398 _tmp = _tmp->next; \
400 if (_tmp->next) { \
401 _tmp->next = (del)->next; \
407 LL_COUNT2(head,el,counter,next) \
409 #define LL_COUNT2(head,el,counter,next) \ argument
412 LL_FOREACH2(head,el,next) { ++(counter); } \
416 LL_FOREACH2(head,el,next)
418 #define LL_FOREACH2(head,el,next) \ argument
419 for ((el) = (head); el; (el) = (el)->next)
422 LL_FOREACH_SAFE2(head,el,tmp,next)
424 #define LL_FOREACH_SAFE2(head,el,tmp,next) \ argument
425 for ((el) = (head); (el) && ((tmp) = (el)->next, 1); (el) = (tmp))
428 LL_SEARCH_SCALAR2(head,out,field,val,next)
430 #define LL_SEARCH_SCALAR2(head,out,field,val,next) \ argument
432 LL_FOREACH2(head,out,next) { \
438 LL_SEARCH2(head,out,elt,cmp,next)
440 #define LL_SEARCH2(head,out,elt,cmp,next) \ argument
442 LL_FOREACH2(head,out,next) { \
447 #define LL_REPLACE_ELEM2(head, el, add, next) \ argument
453 (add)->next = (el)->next; \
458 while (_tmp->next && (_tmp->next != (el))) { \
459 _tmp = _tmp->next; \
461 if (_tmp->next) { \
462 _tmp->next = (add); \
468 LL_REPLACE_ELEM2(head, el, add, next)
470 #define LL_PREPEND_ELEM2(head, el, add, next) \ argument
476 (add)->next = (el); \
481 while (_tmp->next && (_tmp->next != (el))) { \
482 _tmp = _tmp->next; \
484 if (_tmp->next) { \
485 _tmp->next = (add); \
489 LL_APPEND2(head, add, next); \
494 LL_PREPEND_ELEM2(head, el, add, next)
496 #define LL_APPEND_ELEM2(head, el, add, next) \ argument
501 (add)->next = (el)->next; \
502 (el)->next = (add); \
504 LL_PREPEND2(head, add, next); \
509 LL_APPEND_ELEM2(head, el, add, next)
515 #define LL_CONCAT2(head1,head2,next) \ argument
520 while ((head1)->next) { (head1) = (head1)->next; } \
521 (head1)->next = (head2); \
529 #define LL_APPEND2(head,add,next) \ argument
532 (add)->next = head; /* use add->next as a temp variable */ \
533 while ((add)->next->next) { (add)->next = (add)->next->next; } \
534 (add)->next->next=(add); \
538 (add)->next=NULL; \
542 #define LL_INSERT_INORDER2(head,add,cmp,next) \ argument
545 (add)->next = (head); \
549 while ((head)->next != NULL && (cmp((head)->next, add)) < 0) { \
550 (head) = (head)->next; \
552 (add)->next = (head)->next; \
553 (head)->next = (add); \
559 #define LL_DELETE2(head,del,next) \ argument
562 (head)=(head)->next; \
565 while ((head)->next && ((head)->next != (del))) { \
566 (head) = (head)->next; \
568 if ((head)->next) { \
569 (head)->next = ((del)->next); \
576 #define LL_REPLACE_ELEM2(head, el, add, next) \ argument
584 (add)->next = head; \
585 while ((add)->next->next && ((add)->next->next != (el))) { \
586 (add)->next = (add)->next->next; \
588 if ((add)->next->next) { \
589 (add)->next->next = (add); \
592 (add)->next = (el)->next; \
596 #define LL_PREPEND_ELEM2(head, el, add, next) \ argument
604 (add)->next = (head); \
605 while ((add)->next->next && ((add)->next->next != (el))) { \
606 (add)->next = (add)->next->next; \
608 if ((add)->next->next) { \
609 (add)->next->next = (add); \
612 (add)->next = (el); \
614 LL_APPEND2(head, add, next); \
624 DL_PREPEND2(head,add,prev,next)
626 #define DL_PREPEND2(head,add,prev,next) \ argument
628 (add)->next = (head); \
639 DL_APPEND2(head,add,prev,next)
641 #define DL_APPEND2(head,add,prev,next) \ argument
645 (head)->prev->next = (add); \
647 (add)->next = NULL; \
651 (head)->next = NULL; \
656 DL_INSERT_INORDER2(head,add,cmp,prev,next)
658 #define DL_INSERT_INORDER2(head,add,cmp,prev,next) \ argument
662 DL_LOWER_BOUND2(head, _tmp, add, cmp, next); \
663 DL_APPEND_ELEM2(head, _tmp, add, prev, next); \
667 (head)->next = NULL; \
672 DL_LOWER_BOUND2(head,elt,like,cmp,next)
674 #define DL_LOWER_BOUND2(head,elt,like,cmp,next) \ argument
679 for ((elt) = (head); (elt)->next != NULL; (elt) = (elt)->next) { \
680 if ((cmp((elt)->next, like)) >= 0) { \
688 DL_CONCAT2(head1,head2,prev,next)
690 #define DL_CONCAT2(head1,head2,prev,next) \ argument
697 (head1)->prev->next = (head2); \
706 DL_DELETE2(head,del,prev,next)
708 #define DL_DELETE2(head,del,prev,next) \ argument
715 assert((del)->next != NULL); \
716 (del)->next->prev = (del)->prev; \
717 (head) = (del)->next; \
719 (del)->prev->next = (del)->next; \
720 if ((del)->next) { \
721 (del)->next->prev = (del)->prev; \
729 DL_COUNT2(head,el,counter,next) \
731 #define DL_COUNT2(head,el,counter,next) \ argument
734 DL_FOREACH2(head,el,next) { ++(counter); } \
738 DL_FOREACH2(head,el,next)
740 #define DL_FOREACH2(head,el,next) \ argument
741 for ((el) = (head); el; (el) = (el)->next)
745 DL_FOREACH_SAFE2(head,el,tmp,next)
747 #define DL_FOREACH_SAFE2(head,el,tmp,next) \ argument
748 for ((el) = (head); (el) && ((tmp) = (el)->next, 1); (el) = (tmp))
756 #define DL_REPLACE_ELEM2(head, el, add, prev, next) \ argument
763 (add)->next = (el)->next; \
764 if ((el)->next == NULL) { \
768 (add)->next->prev = (add); \
771 (add)->next = (el)->next; \
773 (add)->prev->next = (add); \
774 if ((el)->next == NULL) { \
777 (add)->next->prev = (add); \
783 DL_REPLACE_ELEM2(head, el, add, prev, next)
785 #define DL_PREPEND_ELEM2(head, el, add, prev, next) \ argument
790 (add)->next = (el); \
796 (add)->prev->next = (add); \
799 DL_APPEND2(head, add, prev, next); \
804 DL_PREPEND_ELEM2(head, el, add, prev, next)
806 #define DL_APPEND_ELEM2(head, el, add, prev, next) \ argument
811 (add)->next = (el)->next; \
813 (el)->next = (add); \
814 if ((add)->next) { \
815 (add)->next->prev = (add); \
820 DL_PREPEND2(head, add, prev, next); \
825 DL_APPEND_ELEM2(head, el, add, prev, next)
831 #define DL_INSERT_INORDER2(head,add,cmp,prev,next) \ argument
835 (add)->next = NULL; \
839 (add)->next = (head); \
844 while ((head)->next && (cmp((head)->next, add)) < 0) { \
845 (head) = (head)->next; \
848 (add)->next = (head)->next; \
849 (head)->next = (add); \
851 if ((add)->next) { \
852 (add)->next->prev = (add); \
864 CDL_APPEND2(head,add,prev,next)
866 #define CDL_APPEND2(head,add,prev,next) \ argument
870 (add)->next = (head); \
872 (add)->prev->next = (add); \
875 (add)->next = (add); \
881 CDL_PREPEND2(head,add,prev,next)
883 #define CDL_PREPEND2(head,add,prev,next) \ argument
887 (add)->next = (head); \
889 (add)->prev->next = (add); \
892 (add)->next = (add); \
898 CDL_INSERT_INORDER2(head,add,cmp,prev,next)
900 #define CDL_INSERT_INORDER2(head,add,cmp,prev,next) \ argument
904 CDL_LOWER_BOUND2(head, _tmp, add, cmp, next); \
905 CDL_APPEND_ELEM2(head, _tmp, add, prev, next); \
908 (head)->next = (head); \
914 CDL_LOWER_BOUND2(head,elt,like,cmp,next)
916 #define CDL_LOWER_BOUND2(head,elt,like,cmp,next) \ argument
921 for ((elt) = (head); (elt)->next != (head); (elt) = (elt)->next) { \
922 if ((cmp((elt)->next, like)) >= 0) { \
930 CDL_DELETE2(head,del,prev,next)
932 #define CDL_DELETE2(head,del,prev,next) \ argument
934 if (((head)==(del)) && ((head)->next == (head))) { \
937 (del)->next->prev = (del)->prev; \
938 (del)->prev->next = (del)->next; \
939 if ((del) == (head)) (head)=(del)->next; \
944 CDL_COUNT2(head,el,counter,next) \
946 #define CDL_COUNT2(head, el, counter,next) \ argument
949 CDL_FOREACH2(head,el,next) { ++(counter); } \
953 CDL_FOREACH2(head,el,next)
955 #define CDL_FOREACH2(head,el,next) \ argument
956 for ((el)=(head);el;(el)=(((el)->next==(head)) ? NULL : (el)->next))
959 CDL_FOREACH_SAFE2(head,el,tmp1,tmp2,prev,next)
961 #define CDL_FOREACH_SAFE2(head,el,tmp1,tmp2,prev,next) \ argument
963 (el) && ((tmp2) = (el)->next, 1); \
967 CDL_SEARCH_SCALAR2(head,out,field,val,next)
969 #define CDL_SEARCH_SCALAR2(head,out,field,val,next) \ argument
971 CDL_FOREACH2(head,out,next) { \
977 CDL_SEARCH2(head,out,elt,cmp,next)
979 #define CDL_SEARCH2(head,out,elt,cmp,next) \ argument
981 CDL_FOREACH2(head,out,next) { \
986 #define CDL_REPLACE_ELEM2(head, el, add, prev, next) \ argument
991 if ((el)->next == (el)) { \
992 (add)->next = (add); \
996 (add)->next = (el)->next; \
998 (add)->next->prev = (add); \
999 (add)->prev->next = (add); \
1007 CDL_REPLACE_ELEM2(head, el, add, prev, next)
1009 #define CDL_PREPEND_ELEM2(head, el, add, prev, next) \ argument
1014 (add)->next = (el); \
1017 (add)->prev->next = (add); \
1022 CDL_APPEND2(head, add, prev, next); \
1027 CDL_PREPEND_ELEM2(head, el, add, prev, next)
1029 #define CDL_APPEND_ELEM2(head, el, add, prev, next) \ argument
1034 (add)->next = (el)->next; \
1036 (el)->next = (add); \
1037 (add)->next->prev = (add); \
1039 CDL_PREPEND2(head, add, prev, next); \
1044 CDL_APPEND_ELEM2(head, el, add, prev, next)
1050 #define CDL_INSERT_INORDER2(head,add,cmp,prev,next) \ argument
1054 (add)->next = (add); \
1058 (add)->next = (head); \
1059 (add)->prev->next = (add); \
1064 while ((char*)(head)->next != _tmp && (cmp((head)->next, add)) < 0) { \
1065 (head) = (head)->next; \
1068 (add)->next = (head)->next; \
1069 (add)->next->prev = (add); \
1070 (head)->next = (add); \