__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_drop(
+ __isl_take isl_set_list *list,
+ unsigned first, unsigned n);
__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_##EL##_list *isl_##EL##_list_add( \
__isl_take isl_##EL##_list *list, \
__isl_take struct isl_##EL *el); \
+__isl_give isl_##EL##_list *isl_##EL##_list_drop( \
+ __isl_take isl_##EL##_list *list, unsigned first, unsigned n); \
__isl_give isl_##EL##_list *isl_##EL##_list_concat( \
__isl_take isl_##EL##_list *list1, \
__isl_take isl_##EL##_list *list2); \
return NULL;
}
+/* Remove the "n" elements starting at "first" from "list".
+ */
+__isl_give LIST(EL) *FN(LIST(EL),drop)(__isl_take LIST(EL) *list,
+ unsigned first, unsigned n)
+{
+ int i;
+
+ if (!list)
+ return NULL;
+ if (first + n > list->n || first + n < first)
+ isl_die(list->ctx, isl_error_invalid,
+ "index out of bounds", return FN(LIST(EL),free)(list));
+ if (n == 0)
+ return list;
+ list = FN(LIST(EL),cow)(list);
+ if (!list)
+ return NULL;
+ for (i = 0; i < n; ++i)
+ FN(EL,free)(list->p[first + i]);
+ for (i = first; i + n < list->n; ++i)
+ list->p[i] = list->p[i + n];
+ list->n -= n;
+ return list;
+}
+
void *FN(LIST(EL),free)(__isl_take LIST(EL) *list)
{
int i;
return 0;
}
+static int test_list(isl_ctx *ctx)
+{
+ isl_id *a, *b, *c, *d, *id;
+ isl_id_list *list;
+ int ok;
+
+ a = isl_id_alloc(ctx, "a", NULL);
+ b = isl_id_alloc(ctx, "b", NULL);
+ c = isl_id_alloc(ctx, "c", NULL);
+ d = isl_id_alloc(ctx, "d", NULL);
+
+ list = isl_id_list_alloc(ctx, 4);
+ list = isl_id_list_add(list, a);
+ list = isl_id_list_add(list, b);
+ list = isl_id_list_add(list, c);
+ list = isl_id_list_add(list, d);
+ list = isl_id_list_drop(list, 1, 1);
+
+ if (isl_id_list_n_id(list) != 3) {
+ isl_id_list_free(list);
+ isl_die(ctx, isl_error_unknown,
+ "unexpected number of elements in list", return -1);
+ }
+
+ id = isl_id_list_get_id(list, 0);
+ ok = id == a;
+ isl_id_free(id);
+ id = isl_id_list_get_id(list, 1);
+ ok = ok && id == c;
+ isl_id_free(id);
+ id = isl_id_list_get_id(list, 2);
+ ok = ok && id == d;
+ isl_id_free(id);
+
+ isl_id_list_free(list);
+
+ if (!ok)
+ isl_die(ctx, isl_error_unknown,
+ "unexpected elements in list", return -1);
+
+ return 0;
+}
+
struct {
const char *name;
int (*fn)(isl_ctx *ctx);
} tests [] = {
+ { "list", &test_list },
{ "align parameters", &test_align_parameters },
{ "eliminate", &test_eliminate },
{ "div", &test_div },