22#define xS(TYPE,NAME) struct TYPE ## _ ## NAME
23#define S(TYPE,NAME) xS(TYPE,NAME)
27 return list ? list->ctx : NULL;
36 "cannot create list of negative length",
39 sizeof(
LIST(
EL)) + (
n - 1) *
sizeof(
struct EL *));
71 for (i = 0; i < list->n; ++i)
101 if (list->ref == 1 && list->n + n <= list->
size)
105 new_size = ((list->n +
n + 1) * 3) / 2;
106 if (list->ref == 1) {
108 sizeof(
LIST(
EL)) + (new_size - 1) *
sizeof(
EL *));
111 res->size = new_size;
115 if (list->n + n <= list->
size && list->size < new_size)
116 new_size = list->size;
122 for (i = 0; i < list->n; ++i)
135 if (index < 0 || index >= list->n)
147 list->p[list->n] = el;
159 unsigned first,
unsigned n)
165 if (first +
n > list->n || first +
n < first)
167 "index out of bounds",
return FN(
LIST(
EL),free)(list));
173 for (i = 0; i <
n; ++i)
174 FN(
EL,free)(list->p[first + i]);
175 for (i = first; i +
n < list->n; ++i)
176 list->p[i] = list->p[i +
n];
209 "index out of bounds",
goto error);
211 if (list->ref == 1 && list->size > list->n) {
212 for (i = list->n; i >
pos; --i)
213 list->p[i] = list->p[i - 1];
220 for (i = 0; i <
pos; ++i)
223 for (i =
pos; i < list->n; ++i)
245 for (i = 0; i < list->n; ++i)
246 FN(
EL,free)(list->p[i]);
270 if (
FN(
LIST(
EL),check_index)(list, index) < 0)
272 return list->p[index];
287 return FN(
LIST(
EL),get_at)(list, index);
297 if (
FN(
LIST(
EL),check_index)(list, index) < 0)
299 if (list->p[index] == el) {
306 FN(
EL,free)(list->p[index]);
338 if (
FN(
LIST(
EL),check_index)(list, index) < 0)
343 list->p[index] = NULL;
360 unsigned pos1,
unsigned pos2)
380 for (i = 0; i <
n - 1 - i; ++i)
393 for (i = 0; i < list->n; ++i) {
394 EL *el =
FN(
EL,copy)(list->p[i]);
414 for (i = 0; i < list->n; ++i) {
437 for (i = 0; i <
n; ++i) {
467 return data->cmp(*el1, *el2, data->user);
486 if (
isl_sort(list->p, list->n,
sizeof(list->p[0]),
512 return data->follows(data->list->p[i], data->list->p[j],
528 for (i = 0; i <
n; ++i) {
531 el =
FN(
EL,copy)(list->p[
pos[i]]);
555 S(
LIST(
EL),foreach_scc_data) data = { list, follows, follows_user };
577 if (g->
order[i] == -1)
581 while (g->
order[i] != -1) {
584 if (first == 0 &&
n == 0) {
588 if (
FN(
LIST(
EL),call_on_scc)(list, g->
order + first, i - first,
606 ctx =
FN(
EL,get_ctx)(el);
634 for (i = 0; i < list2->n; ++i)
652 if (!list1 || !list2)
655 if (list1->ref == 1 && list1->n + list2->n <= list1->size)
656 return FN(
LIST(
EL),concat_inplace)(list1, list2);
659 res =
FN(
LIST(
EL),alloc)(ctx, list1->n + list2->n);
660 for (i = 0; i < list1->n; ++i)
662 for (i = 0; i < list2->n; ++i)
682 for (i = 0; i < list->n; ++i) {
695#define BASE LIST(EL_BASE)
697#define PRINT_DUMP_DEFAULT 0
699#undef PRINT_DUMP_DEFAULT
#define isl_die(ctx, errno, msg, code)
void isl_ctx_deref(struct isl_ctx *ctx)
#define isl_alloc(ctx, type, size)
void isl_ctx_ref(struct isl_ctx *ctx)
#define isl_realloc(ctx, ptr, type, size)
isl_stat isl_stat(* fn)(__isl_take ISL_KEY *key, __isl_take ISL_VAL *val, void *user)
isl_stat isl_stat(*) void user)
isl_bool isl_bool(* test)(__isl_keep ISL_KEY *key, __isl_keep ISL_VAL *val, void *user)
void GMPQAPI() clear(mp_rat x)
int GMPQAPI() cmp(mp_rat op1, mp_rat op2)
void GMPZAPI() swap(mp_int rop1, mp_int rop2)
void GMPZAPI() add(mp_int rop, mp_int op1, mp_int op2)
static void drop(struct isl_coalesce_info *info)
__isl_give dup(__isl_keep LIST(EL) *list)
static unsigned pos(__isl_keep isl_space *space, enum isl_dim_type type)
int isl_sort(void *const pbase, size_t total_elems, size_t size, int(*cmp)(const void *, const void *, void *arg), void *arg)
struct isl_tarjan_graph * isl_tarjan_graph_free(struct isl_tarjan_graph *g)
struct isl_tarjan_graph * isl_tarjan_graph_init(isl_ctx *ctx, int len, isl_bool(*follows)(int i, int j, void *user), void *user)
__isl_null isl_printer * isl_printer_free(__isl_take isl_printer *printer)
__isl_give isl_printer * isl_printer_print_str(__isl_take isl_printer *p, const char *s)
static std::vector< Signature > set_at