21 #ifndef __CCL_LIST_H__
22 # define __CCL_LIST_H__
44 # ifndef IN_DOXYGEN_DOC
60 # define FIRST(l) ((l)->first)
65 # define CAR(p) ((p)->car)
70 # define CDR(p) ((p)->cdr)
75 # define CADR(p) (CAR (CDR (p)))
80 # define CDDR(p) (CDR (CDR (p)))
85 # define CADDR(p) (CAR (CDDR (p)))
90 # define CDDDR(p) (CDR (CDDR (p)))
95 # define CADDDR(p) (CAR (CDDDR (p)))
100 # define CDDDDR(p) (CDR (CDDDR (p)))
105 # define CADDDDR(p) (CAR (CDDDDR (p)))
110 # define CDDDDDR(p) (CDR (CDDDDR (p)))
112 # define CCL_LIST_FOREACH(p,l) for ((p)=FIRST(l); (p); (p) = CDR (p))
168 # define ccl_list_get_size(l) (ccl_pre ((l) != NULL), (l)->size)
176 # define ccl_list_get_length(l) ccl_list_get_size(l)
184 # define ccl_list_is_empty(l) (ccl_list_get_size (l) ==0)
247 ccl_list_sort_with_data (
ccl_list *l, ccl_compare_with_data_func *cmp,
270 ccl_list_insert_before (
ccl_list *l,
void *obj,
void *inserted);
273 ccl_list_insert_after (
ccl_list *l,
void *obj,
void *inserted);
343 ccl_list_remove_filtered (
ccl_list *l,
int (*filter)(
void *p,
void *data),
451 extern ccl_pointer_iterator *
456 ccl_list_create_from_iterator (ccl_pointer_iterator *i);
459 ccl_list_map (
const ccl_list *l, ccl_map_proc *map,
void *data);
int ccl_list_get_index(const ccl_list *l, void *ptr, ccl_compare_func *cmp)
Returns the position of ptr in the list l.
void ccl_list_delete(ccl_list *l)
Deletes the list l.
Frequently used prototypes of generic functions.
int ccl_list_compare(const ccl_list *l1, const ccl_list *l2, ccl_compare_func *cmp)
Compares the two lists l1 and l2 with the lexicographical order.
ccl_list * ccl_list_deep_dup(const ccl_list *l, ccl_duplicate_func *dup)
Duplicates the list l and stored objects.
A generic iterator interface.
ccl_list * ccl_list_dup(const ccl_list *l)
Duplicates the list l.
unsigned int ccl_list_hash(const ccl_list *l)
Computes a hashed value for the list l.
void ccl_list_remove(ccl_list *l, void *p)
Removes the object p from the list l.
unsigned int ccl_list_hash_all(const ccl_list *l, ccl_hash_func *h)
Computes a hashed value for the list l.
void ccl_list_clear(ccl_list *l, ccl_delete_proc *del)
Makes empty the list l.
int ccl_compare_func(const void *ptr1, const void *ptr2)
Prototype of functions used to order two objects pointed respectively by ptr1 and ptr2...
void * ccl_list_take_first(ccl_list *l)
Removes the first object of the list l.
struct ccl_pair_st ccl_pair
Type of a cell of a ccl_list.
struct ccl_list_st ccl_list
Type of a generic list.
void ccl_delete_proc(void *ptr)
Prototype of procedures used to release the resources allocated to the object pointed by ptr...
int ccl_list_equals(const ccl_list *l1, const ccl_list *l2)
Checks if l1 and l2 are equals.
void ccl_list_clear_and_delete(ccl_list *l, ccl_delete_proc *del)
Deletes the list l and stored objects.
void ccl_list_add(ccl_list *l, void *obj)
Adds an object obj at the end of the list l.
ccl_list * ccl_list_create(void)
Creates a new list.
void * ccl_list_get_at(ccl_list *l, int index)
Returns the object at the postion index.
void ccl_list_put_first(ccl_list *l, void *obj)
Adds an object obj at the beginning of the list l.
void * ccl_duplicate_func(void *ptr)
Prototype of functions used to duplicate an object pointed by ptr.
void ccl_list_append(ccl_list *l1, const ccl_list *l2)
append l2 to l1
Macros allowing to set assertions into the code.
int ccl_list_insert(ccl_list *l, void *obj, ccl_compare_func *cmp)
Inserts the object obj into the ordered list l.
void ** ccl_list_to_array(const ccl_list *l, int *p_size)
Return a newly allocated array containing all elements of l.
int ccl_list_has(const ccl_list *l, void *obj)
Checks if the object obj belongs to l.
void ccl_list_sub(ccl_list *l1, const ccl_list *l2)
Removes the objects of l2 from l1.
unsigned int ccl_hash_func(const void *ptr)
Prototype of functions used to compute a hashed value from an abstract object pointed by ptr...
void ccl_list_sort(ccl_list *l, ccl_compare_func *cmp)
(Quick-)Sort the list l using the comparison function cmp. If cmp == CCL_DEFAULT_COMPARE_FUNC, addresses of objects are compared.