26 #error Define LIST_ELEM before including
30 #include <list_void.h>
33 #define LIST_CON(a,b) a ## _ ## b
34 #define LIST_CAT(a,b) LIST_CON(a,b)
36 #define LIST LIST_CAT(LIST_ELEM, list)
40 typedef struct LIST LIST;
42 typedef double (*LIST_CAT(LIST, func_eval))(
const LIST_ELEM *,
45 typedef bool (*LIST_CAT(LIST, func_lt))(
const LIST_ELEM *,
49 typedef bool (*LIST_CAT(LIST, func_predicate))(
const LIST_ELEM *,
57 LIST_CAT(LIST,
new)(void)
68 LIST_CAT(LIST, duplicate)(
const LIST *l,
69 LIST_ELEM * (*duplicate)(
const LIST_ELEM *))
74 (
void *(*)(
const void *)) duplicate);
81 LIST_CAT(LIST,
delete)(LIST **l,
82 void (*ldelete)(LIST_ELEM **))
85 list_delete((
list **)l, (
void (*)(
void **))ldelete);
92 LIST_CAT(LIST, delete_const)(
const LIST **l,
93 void (*ldelete)(LIST_ELEM **))
96 list_delete_const((
const list **)l, (
void (*)(
void **))ldelete);
103 LIST_CAT(LIST, insert)(LIST *l, LIST_ELEM *e)
106 list_insert((
list *)l, e);
113 LIST_CAT(LIST, reverse)(LIST *l)
116 list_reverse((
list *)l);
123 LIST_CAT(LIST, size)(
const LIST *l)
126 return list_size((
const list *)l);
134 LIST_CAT(LIST, first)(LIST *l)
137 return (LIST_ELEM*)list_first((
list *)l);
145 LIST_CAT(LIST, next)(LIST *l)
148 return (LIST_ELEM*)list_next((
list *)l);
156 LIST_CAT(LIST, first_const)(
const LIST *l)
159 return (
const LIST_ELEM*)list_first_const((
list *)l);
167 LIST_CAT(LIST, next_const)(
const LIST *l)
170 return (
const LIST_ELEM*)list_next_const((
const list *)l);
177 LIST_CAT(LIST, first_pair)(LIST *l,
182 list_first_pair((
list *)l, (
void **)e1, (
void **)e2);
190 LIST_CAT(LIST, next_pair)(LIST *l,
195 list_next_pair((
list *)l, (
void **)e1, (
void **)e2);
203 LIST_CAT(LIST, first_pair_const)(
const LIST *l,
204 const LIST_ELEM **e1,
205 const LIST_ELEM **e2)
208 list_first_pair((
list *)l, (
void **)e1, (
void **)e2);
215 LIST_CAT(LIST, next_pair_const)(
const LIST *l,
216 const LIST_ELEM **e1,
217 const LIST_ELEM **e2)
220 list_next_pair((
list *)l, (
void **)e1, (
void **)e2);
228 LIST_CAT(LIST, remove_const)(LIST *l,
const LIST_ELEM *e)
231 return (
const LIST_ELEM*)list_remove_const((
list *)l, e);
238 LIST_CAT(LIST,
remove)(LIST *l, LIST_ELEM *e)
241 return (LIST_ELEM*)list_remove((
list *)l, e);
249 LIST_CAT(LIST, extract)(
const LIST *l,
250 LIST_ELEM * (*duplicate)(
const LIST_ELEM *),
251 LIST_CAT(LIST, func_predicate) predicate,
256 (
void *(*)(
const void *))duplicate,
257 (list_func_predicate) predicate,
266 LIST_CAT(LIST, max_const)(
const LIST *l,
267 LIST_CAT(LIST, func_lt) less_than,
271 return (
const LIST_ELEM*)list_max_const((
list *)l,
272 (list_func_lt) less_than,
280 LIST_CAT(LIST, max)(LIST *l,
281 LIST_CAT(LIST, func_lt) less_than,
285 return (LIST_ELEM*)list_max((
list *)l,
286 (list_func_lt) less_than,
294 LIST_CAT(LIST, min)(LIST *l,
295 LIST_CAT(LIST, func_lt) less_than,
299 return (LIST_ELEM*)list_min((
list *)l,
300 (list_func_lt) less_than,
309 LIST_CAT(LIST, min_val)(LIST *l,
310 LIST_CAT(LIST, func_eval) eval,
314 return (LIST_ELEM*)list_min_val((
list *)l,
315 (list_func_eval) eval,
324 LIST_CAT(LIST, max_val)(LIST *l,
325 LIST_CAT(LIST, func_eval) eval,
329 return (LIST_ELEM*)list_max_val((
list *)l,
330 (list_func_eval) eval,
339 LIST_CAT(LIST, kth_const)(
const LIST *l,
int k,
340 LIST_CAT(LIST, func_lt) less_than,
344 return (
const LIST_ELEM*)list_kth_const((
list *)l, k,
345 (list_func_lt) less_than,
353 LIST_CAT(LIST, kth)(LIST *l,
int k,
354 LIST_CAT(LIST, func_lt) less_than,
358 return (LIST_ELEM*)list_kth((
list *)l, k,
359 (list_func_lt) less_than,
368 LIST_CAT(LIST, kth_val)(LIST *l,
int k,
369 LIST_CAT(LIST, func_eval) eval,
373 return (LIST_ELEM*)list_kth_val((
list *)l, k,
374 (list_func_eval) eval,
384 LIST_CAT(LIST, kth_val_const)(
const LIST *l,
int k,
385 LIST_CAT(LIST, func_eval) eval,
389 return (
const LIST_ELEM*)list_kth_val_const((
const list *)l, k,
390 (list_func_eval) eval,
401 LIST_CAT(LIST, mean)(LIST *l,
402 LIST_CAT(LIST, func_eval) eval,
406 return list_mean((
list *)l,
407 (list_func_eval) eval,
415 LIST_CAT(LIST, mean_optimal)(LIST *l,
416 LIST_CAT(LIST, func_eval) eval,
void *data_eval,
417 LIST_CAT(LIST, func_eval) eval_err,
void *data_err,
422 return list_mean_optimal((
list *)l,
423 (list_func_eval) eval, data_eval,
424 (list_func_eval) eval_err, data_err,
434 LIST_CAT(LIST, median)(
const LIST *l,
435 LIST_CAT(LIST, func_eval) eval,
439 return list_median((
const list *)l,
440 (list_func_eval) eval,
449 LIST_CAT(LIST, mad)(LIST *l,
450 LIST_CAT(LIST, func_eval) eval,
454 return list_mad((
list *)l,
455 (list_func_eval) eval,
list * list_duplicate(const list *l, void *(*duplicate)(const void *))
Copy constructor.
list * list_extract(const list *l, void *(*duplicate)(const void *), bool(*predicate)(const void *, void *), void *data)
Extract elements.
list * list_new(void)
Constructor.