Lists are defined over several element types, including
C<isl_aff>, C<isl_pw_aff>, C<isl_basic_set> and C<isl_set>.
Here we take lists of C<isl_set>s as an example.
-Lists can be created, copied and freed using the following functions.
+Lists can be created, copied, modified and freed using the following functions.
#include <isl/list.h>
__isl_give isl_set_list *isl_set_list_from_set(
__isl_give isl_set_list *isl_set_list_add(
__isl_take isl_set_list *list,
__isl_take isl_set *el);
+ __isl_give isl_set_list *isl_set_list_set_set(
+ __isl_take isl_set_list *list, int index,
+ __isl_take isl_set *set);
__isl_give isl_set_list *isl_set_list_concat(
__isl_take isl_set_list *list1,
__isl_take isl_set_list *list2);
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); \
+__isl_give struct isl_##EL##_list *isl_##EL##_list_set_##EL( \
+ __isl_take struct isl_##EL##_list *list, int index, \
+ __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); \
return dup;
}
+__isl_give LIST(EL) *FN(LIST(EL),cow)(__isl_take LIST(EL) *list)
+{
+ if (!list)
+ return NULL;
+
+ if (list->ref == 1)
+ return list;
+ list->ref--;
+ return FN(LIST(EL),dup)(list);
+}
+
__isl_give LIST(EL) *FN(LIST(EL),add)(__isl_take LIST(EL) *list,
__isl_take struct EL *el)
{
return FN(EL,copy)(list->p[index]);
}
+/* Replace the element at position "index" in "list" by "el".
+ */
+__isl_give LIST(EL) *FN(FN(LIST(EL),set),BASE)(__isl_take LIST(EL) *list,
+ int index, __isl_take EL *el)
+{
+ if (!list || !el)
+ goto error;
+ if (index < 0 || index >= list->n)
+ isl_die(list->ctx, isl_error_invalid,
+ "index out of bounds", goto error);
+ if (list->p[index] == el) {
+ FN(EL,free)(el);
+ return list;
+ }
+ list = FN(LIST(EL),cow)(list);
+ if (!list)
+ goto error;
+ FN(EL,free)(list->p[index]);
+ list->p[index] = el;
+ return list;
+error:
+ FN(EL,free)(el);
+ FN(LIST(EL),free)(list);
+ return NULL;
+}
+
int FN(LIST(EL),foreach)(__isl_keep LIST(EL) *list,
int (*fn)(__isl_take EL *el, void *user), void *user)
{