# HG changeset patch # User Mike Becker # Date 1640709711 -3600 # Node ID e66551b47466234acad221d4dddd47c1f853d1a3 # Parent af6be1e123aaf44928891f7289b055ceaacf228a add cxListReverse() diff -r af6be1e123aa -r e66551b47466 src/cx/list.h --- a/src/cx/list.h Tue Dec 28 17:38:02 2021 +0100 +++ b/src/cx/list.h Tue Dec 28 17:41:51 2021 +0100 @@ -114,6 +114,11 @@ cx_list_s const *list, cx_list_s const *other ); + + /** + * Member function for reversing the order of the items. + */ + void (*reverse)(cx_list_s *list); } cx_list_class; /** @@ -249,6 +254,15 @@ } /** + * Reverses the order of the items. + * + * @param list the list + */ +static inline void cxListReverse(CxList list) { + list->cl->reverse(list); +} + +/** * Compares a list to another list of the same type. * * First, the list sizes are compared. If they match, the lists are compared element-wise. diff -r af6be1e123aa -r e66551b47466 src/linked_list.c --- a/src/linked_list.c Tue Dec 28 17:38:02 2021 +0100 +++ b/src/linked_list.c Tue Dec 28 17:41:51 2021 +0100 @@ -613,6 +613,11 @@ true, list->cmpfunc); } +static void cx_ll_reverse(cx_list_s *list) { + cx_linked_list *ll = (cx_linked_list *) list; + cx_linked_list_reverse((void **) &ll->begin, (void **) ll->end, CX_LL_LOC_PREV, CX_LL_LOC_NEXT); +} + static int cx_ll_compare( cx_list_s const *list, cx_list_s const *other @@ -642,7 +647,8 @@ cx_ll_at, cx_ll_find, cx_ll_sort, - cx_ll_compare + cx_ll_compare, + cx_ll_reverse }; static cx_list_class cx_pointer_linked_list_class = { @@ -652,7 +658,8 @@ cx_pll_at, cx_pll_find, cx_pll_sort, - cx_pll_compare + cx_pll_compare, + cx_ll_reverse }; CxList cxLinkedListCreate(