summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSven Verdoolaege <skimo@kotnet.org>2011-04-16 14:55:10 +0200
committerSven Verdoolaege <skimo@kotnet.org>2011-06-04 13:19:23 +0200
commit88f7a78a974d4f6689835b82d5e3cc008667aff0 (patch)
tree39926dbc9838f752b6d3ebb183ba1afda6c4fcfe
parent0a2cf69b577640926186fbf62c0d9c2759236270 (diff)
downloadisl-88f7a78a974d4f6689835b82d5e3cc008667aff0.tar.gz
isl-88f7a78a974d4f6689835b82d5e3cc008667aff0.tar.bz2
isl-88f7a78a974d4f6689835b82d5e3cc008667aff0.zip
add *_list_foreach
Signed-off-by: Sven Verdoolaege <skimo@kotnet.org>
-rw-r--r--doc/user.pod3
-rw-r--r--include/isl/list.h4
-rw-r--r--isl_list_templ.c19
3 files changed, 25 insertions, 1 deletions
diff --git a/doc/user.pod b/doc/user.pod
index 370bc9c0..3e389c02 100644
--- a/doc/user.pod
+++ b/doc/user.pod
@@ -2025,6 +2025,9 @@ Lists can be inspected using the following functions.
#include <isl/list.h>
isl_ctx *isl_set_list_get_ctx(__isl_keep isl_set_list *list);
+ int isl_set_list_foreach(__isl_keep isl_set_list *list,
+ int (*fn)(__isl_take struct isl_set *el, void *user),
+ void *user);
=head2 Matrices
diff --git a/include/isl/list.h b/include/isl/list.h
index ddedaf33..ce251b4b 100644
--- a/include/isl/list.h
+++ b/include/isl/list.h
@@ -27,7 +27,9 @@ __isl_give isl_##EL##_list *isl_##EL##_list_copy( \
void isl_##EL##_list_free(__isl_take isl_##EL##_list *list); \
__isl_give isl_##EL##_list *isl_##EL##_list_add( \
__isl_take isl_##EL##_list *list, \
- __isl_take struct isl_##EL *el);
+ __isl_take struct isl_##EL *el); \
+int isl_##EL##_list_foreach(__isl_keep isl_##EL##_list *list, \
+ int (*fn)(__isl_take struct isl_##EL *el, void *user), void *user);
ISL_DECLARE_LIST(basic_set)
ISL_DECLARE_LIST(set)
diff --git a/isl_list_templ.c b/isl_list_templ.c
index 4fb89659..bd940236 100644
--- a/isl_list_templ.c
+++ b/isl_list_templ.c
@@ -84,3 +84,22 @@ void FN(LIST(EL),free)(__isl_take LIST(EL) *list)
FN(EL,free)(list->p[i]);
free(list);
}
+
+int FN(LIST(EL),foreach)(__isl_keep LIST(EL) *list,
+ int (*fn)(__isl_take EL *el, void *user), void *user)
+{
+ int i;
+
+ if (!list)
+ return -1;
+
+ for (i = 0; i < list->n; ++i) {
+ EL *el = FN(EL,copy(list->p[i]));
+ if (!el)
+ return -1;
+ if (fn(el, user) < 0)
+ return -1;
+ }
+
+ return 0;
+}