58 |
58 |
59 size_t cx_linked_list_find( |
59 size_t cx_linked_list_find( |
60 void *start, |
60 void *start, |
61 ptrdiff_t loc_advance, |
61 ptrdiff_t loc_advance, |
62 ptrdiff_t loc_data, |
62 ptrdiff_t loc_data, |
63 int follow_ptr, |
63 bool follow_ptr, |
64 CxListComparator cmp_func, |
64 CxListComparator cmp_func, |
65 void *elem |
65 void *elem |
66 ) { |
66 ) { |
67 assert(start != NULL); |
67 assert(start != NULL); |
68 assert(loc_advance >= 0); |
68 assert(loc_advance >= 0); |
399 int cx_linked_list_compare( |
399 int cx_linked_list_compare( |
400 void *begin_left, |
400 void *begin_left, |
401 void *begin_right, |
401 void *begin_right, |
402 ptrdiff_t loc_advance, |
402 ptrdiff_t loc_advance, |
403 ptrdiff_t loc_data, |
403 ptrdiff_t loc_data, |
404 int follow_ptr, |
404 bool follow_ptr, |
405 CxListComparator cmp_func |
405 CxListComparator cmp_func |
406 ) { |
406 ) { |
407 void *left = begin_left, *right = begin_right; |
407 void *left = begin_left, *right = begin_right; |
408 |
408 |
409 while (left != NULL && right != NULL) { |
409 while (left != NULL && right != NULL) { |
585 cx_list_s *list, |
585 cx_list_s *list, |
586 void *elem |
586 void *elem |
587 ) { |
587 ) { |
588 return cx_linked_list_find(((cx_linked_list *) list)->begin, |
588 return cx_linked_list_find(((cx_linked_list *) list)->begin, |
589 CX_LL_LOC_NEXT, CX_LL_LOC_DATA, |
589 CX_LL_LOC_NEXT, CX_LL_LOC_DATA, |
590 0, list->cmpfunc, elem); |
590 false, list->cmpfunc, elem); |
591 } |
591 } |
592 |
592 |
593 static size_t cx_pll_find( |
593 static size_t cx_pll_find( |
594 cx_list_s *list, |
594 cx_list_s *list, |
595 void *elem |
595 void *elem |
596 ) { |
596 ) { |
597 return cx_linked_list_find(((cx_linked_list *) list)->begin, |
597 return cx_linked_list_find(((cx_linked_list *) list)->begin, |
598 CX_LL_LOC_NEXT, CX_LL_LOC_DATA, |
598 CX_LL_LOC_NEXT, CX_LL_LOC_DATA, |
599 1, list->cmpfunc, elem); |
599 true, list->cmpfunc, elem); |
600 } |
600 } |
601 |
601 |
602 static void cx_ll_sort(cx_list_s *list) { |
602 static void cx_ll_sort(cx_list_s *list) { |
603 cx_linked_list *ll = (cx_linked_list *) list; |
603 cx_linked_list *ll = (cx_linked_list *) list; |
604 cx_linked_list_sort((void **) &ll->begin, (void **) &ll->end, |
604 cx_linked_list_sort((void **) &ll->begin, (void **) &ll->end, |
605 CX_LL_LOC_PREV, CX_LL_LOC_NEXT, CX_LL_LOC_DATA, |
605 CX_LL_LOC_PREV, CX_LL_LOC_NEXT, CX_LL_LOC_DATA, |
606 0, list->cmpfunc); |
606 false, list->cmpfunc); |
607 } |
607 } |
608 |
608 |
609 static void cx_pll_sort(cx_list_s *list) { |
609 static void cx_pll_sort(cx_list_s *list) { |
610 cx_linked_list *ll = (cx_linked_list *) list; |
610 cx_linked_list *ll = (cx_linked_list *) list; |
611 cx_linked_list_sort((void **) &ll->begin, (void **) &ll->end, |
611 cx_linked_list_sort((void **) &ll->begin, (void **) &ll->end, |
612 CX_LL_LOC_PREV, CX_LL_LOC_NEXT, CX_LL_LOC_DATA, |
612 CX_LL_LOC_PREV, CX_LL_LOC_NEXT, CX_LL_LOC_DATA, |
613 1, list->cmpfunc); |
613 true, list->cmpfunc); |
614 } |
614 } |
615 |
615 |
616 static cx_list_class cx_linked_list_class = { |
616 static cx_list_class cx_linked_list_class = { |
617 cx_ll_add, |
617 cx_ll_add, |
618 cx_ll_insert, |
618 cx_ll_insert, |