From ce84a51103bb07ccaac16dabe524cdd2bde7ac07 Mon Sep 17 00:00:00 2001 From: Sven Verdoolaege Date: Tue, 24 Apr 2018 11:22:24 +0200 Subject: [PATCH] add isl_*_list_reverse Signed-off-by: Sven Verdoolaege --- doc/user.pod | 3 +++ include/isl/list.h | 2 ++ isl_list_templ.c | 12 ++++++++++++ 3 files changed, 17 insertions(+) diff --git a/doc/user.pod b/doc/user.pod index a02bb87a..5d23357b 100644 --- a/doc/user.pod +++ b/doc/user.pod @@ -7848,6 +7848,8 @@ Lists can be created, copied, modified and freed using the following functions. __isl_give isl_set_list *isl_set_list_swap( __isl_take isl_set_list *list, unsigned pos1, unsigned pos2); + __isl_give isl_set_list *isl_set_list_reverse( + __isl_take isl_set_list *list); __isl_give isl_set_list *isl_set_list_set_set( __isl_take isl_set_list *list, int index, __isl_take isl_set *set); @@ -7872,6 +7874,7 @@ for C elements. C and C add elements to a list, increasing its capacity as needed. C creates a list with a single element. C swaps the elements at the specified locations. +C reverses the elements in the list. Lists can be inspected using the following functions. diff --git a/include/isl/list.h b/include/isl/list.h index 22558f26..49d2f914 100644 --- a/include/isl/list.h +++ b/include/isl/list.h @@ -41,6 +41,8 @@ __isl_give isl_##EL##_list *isl_##EL##_list_drop( \ __isl_give isl_##EL##_list *isl_##EL##_list_swap( \ __isl_take isl_##EL##_list *list, unsigned pos1, \ unsigned pos2); \ +__isl_give isl_##EL##_list *isl_##EL##_list_reverse( \ + __isl_take isl_##EL##_list *list); \ __isl_give isl_##EL##_list *isl_##EL##_list_concat( \ __isl_take isl_##EL##_list *list1, \ __isl_take isl_##EL##_list *list2); \ diff --git a/isl_list_templ.c b/isl_list_templ.c index 116e512f..edd62415 100644 --- a/isl_list_templ.c +++ b/isl_list_templ.c @@ -358,6 +358,18 @@ __isl_give LIST(EL) *FN(LIST(EL),swap)(__isl_take LIST(EL) *list, return list; } +/* Reverse the elements of "list". + */ +__isl_give LIST(EL) *FN(LIST(EL),reverse)(__isl_take LIST(EL) *list) +{ + int i, n; + + n = FN(LIST(EL),size)(list); + for (i = 0; i < n - 1 - i; ++i) + list = FN(LIST(EL),swap)(list, i, n - 1 - i); + return list; +} + isl_stat FN(LIST(EL),foreach)(__isl_keep LIST(EL) *list, isl_stat (*fn)(__isl_take EL *el, void *user), void *user) { -- 2.11.4.GIT