src/linked_list.c

changeset 486
d7ca126eab7f
parent 481
eef025d82a34
child 487
4bd19279778c
equal deleted inserted replaced
485:6a86ad3d8c03 486:d7ca126eab7f
394 } 394 }
395 if (end) *end = cx_linked_list_last(sorted, loc_next); 395 if (end) *end = cx_linked_list_last(sorted, loc_next);
396 } 396 }
397 } 397 }
398 398
399 int cx_linked_list_compare(
400 void *begin_left,
401 void *begin_right,
402 ptrdiff_t loc_advance,
403 ptrdiff_t loc_data,
404 int follow_ptr,
405 CxListComparator cmp_func
406 ) {
407 void *left = begin_left, *right = begin_right;
408
409 while (left != NULL && right != NULL) {
410 int result = cmp_func(ll_data(left), ll_data(right));
411 if (result != 0) return result;
412 left = ll_advance(left);
413 right = ll_advance(right);
414 }
415
416 if (left != NULL) { return 1; }
417 else if (right != NULL) { return -1; }
418 else { return 0; }
419 }
420
399 void cx_linked_list_reverse( 421 void cx_linked_list_reverse(
400 void **begin, 422 void **begin,
401 void **end, 423 void **end,
402 ptrdiff_t loc_prev, 424 ptrdiff_t loc_prev,
403 ptrdiff_t loc_next 425 ptrdiff_t loc_next

mercurial