From 7bd0f96e50c3cfa8bdef67b4138152b676f35a31 Mon Sep 17 00:00:00 2001 From: Sven Verdoolaege Date: Wed, 27 Apr 2011 12:51:19 +0200 Subject: [PATCH] add *list_get_* Signed-off-by: Sven Verdoolaege --- doc/user.pod | 2 ++ include/isl/list.h | 2 ++ isl_list_templ.c | 10 ++++++++++ 3 files changed, 14 insertions(+) diff --git a/doc/user.pod b/doc/user.pod index e7e89802..4511f667 100644 --- a/doc/user.pod +++ b/doc/user.pod @@ -2026,6 +2026,8 @@ Lists can be inspected using the following functions. #include isl_ctx *isl_set_list_get_ctx(__isl_keep isl_set_list *list); int isl_set_list_n_set(__isl_keep isl_set_list *list); + __isl_give struct isl_set *isl_set_list_get_set( + __isl_keep isl_set_list *list, int index); int isl_set_list_foreach(__isl_keep isl_set_list *list, int (*fn)(__isl_take struct isl_set *el, void *user), void *user); diff --git a/include/isl/list.h b/include/isl/list.h index bbbc16d5..1a4a3623 100644 --- a/include/isl/list.h +++ b/include/isl/list.h @@ -29,6 +29,8 @@ __isl_give isl_##EL##_list *isl_##EL##_list_add( \ __isl_take isl_##EL##_list *list, \ __isl_take struct isl_##EL *el); \ int isl_##EL##_list_n_##EL(__isl_keep isl_##EL##_list *list); \ +__isl_give struct isl_##EL *isl_##EL##_list_get_##EL( \ + __isl_keep isl_##EL##_list *list, int index); \ int isl_##EL##_list_foreach(__isl_keep isl_##EL##_list *list, \ int (*fn)(__isl_take struct isl_##EL *el, void *user), void *user); diff --git a/isl_list_templ.c b/isl_list_templ.c index 1e561581..baae501f 100644 --- a/isl_list_templ.c +++ b/isl_list_templ.c @@ -90,6 +90,16 @@ int FN(FN(LIST(EL),n),BASE)(__isl_keep LIST(EL) *list) return list ? list->n : 0; } +__isl_give EL *FN(FN(LIST(EL),get),BASE)(__isl_keep LIST(EL) *list, int index) +{ + if (!list) + return NULL; + if (index < 0 || index >= list->n) + isl_die(list->ctx, isl_error_invalid, + "index out of bounds", return NULL); + return FN(EL,copy)(list->p[index]); +} + int FN(LIST(EL),foreach)(__isl_keep LIST(EL) *list, int (*fn)(__isl_take EL *el, void *user), void *user) { -- 2.11.4.GIT