2 * written for mutt-ng by:
3 * Rocco Rutte <pdmef@cs.tu-berlin.de>
5 * This file is part of mutt-ng, see http://www.muttng.org/.
6 * It's licensed under the GNU General Public License,
7 * please see the file GPL in the top level source directory.
11 * this aims to provide a generic list
12 * implementation using arrays only
19 #include <sys/types.h>
21 typedef struct list2_t {
30 list2_t* list_new (void);
31 /* frees all memory used by list and optionally used edel func
32 * ptr to free items */
33 void list_del (list2_t**, void (*edel) (void**));
35 #define list_empty(l) (!l || l->length == 0 || !l->data)
39 * the list_push_* functions create a list if empty so far
42 void list_push_back (list2_t**, void*);
43 void list_push_front (list2_t**, void*);
44 void* list_pop_back (list2_t*);
45 void* list_pop_front (list2_t*);
46 void* list_pop_idx (list2_t*, int);
53 list2_t* list_cpy (list2_t*);
54 /* "hard copy" using callback to copy items */
55 list2_t* list_dup (list2_t*, void* (*dup) (void*));
61 /* looks up item in list using callback function and comparison item
64 * index in data array otherwise
65 * the callback must return 0 on equality
67 int list_lookup (list2_t*, int (*cmp) (const void*, const void*), const void*);
69 #endif /* !_LIB_LIST_H */