4 * Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
26 /* Chained list struct */
27 struct __alpm_list_t
{
29 struct __alpm_list_t
*prev
;
30 struct __alpm_list_t
*next
;
33 /* TODO we should do away with these... they're messy*/
34 #define _FREELIST(p, f) do { alpm_list_free_inner(p, f); alpm_list_free(p); p = NULL; } while(0)
35 #define FREELIST(p) _FREELIST(p, free)
36 #define FREELISTPTR(p) do { alpm_list_free(p); p = NULL; } while(0)
38 typedef void (*alpm_list_fn_free
)(void *); /* item deallocation callback */
39 typedef int (*alpm_list_fn_cmp
)(const void *, const void *); /* item comparison callback */
42 alpm_list_t
*alpm_list_new(void);
43 void alpm_list_free(alpm_list_t
*list
);
44 void alpm_list_free_inner(alpm_list_t
*list
, alpm_list_fn_free fn
);
47 alpm_list_t
*alpm_list_add(alpm_list_t
*list
, void *data
);
48 alpm_list_t
*alpm_list_add_sorted(alpm_list_t
*list
, void *data
, alpm_list_fn_cmp fn
);
49 alpm_list_t
*alpm_list_mmerge(alpm_list_t
*left
, alpm_list_t
*right
, alpm_list_fn_cmp fn
);
50 alpm_list_t
*alpm_list_msort(alpm_list_t
*list
, int n
, alpm_list_fn_cmp fn
);
51 alpm_list_t
*alpm_list_remove(alpm_list_t
*haystack
, const void *needle
, alpm_list_fn_cmp fn
, void **data
);
52 alpm_list_t
*alpm_list_remove_node(alpm_list_t
*node
);
53 alpm_list_t
*alpm_list_remove_dupes(alpm_list_t
*list
);
54 alpm_list_t
*alpm_list_strdup(alpm_list_t
*list
);
55 alpm_list_t
*alpm_list_reverse(alpm_list_t
*list
);
58 alpm_list_t
*alpm_list_first(alpm_list_t
*list
);
59 alpm_list_t
*alpm_list_nth(alpm_list_t
*list
, int n
);
60 alpm_list_t
*alpm_list_next(alpm_list_t
*list
);
61 alpm_list_t
*alpm_list_last(alpm_list_t
*list
);
62 void *alpm_list_getdata(const alpm_list_t
*entry
);
65 int alpm_list_count(const alpm_list_t
*list
);
66 int alpm_list_find(alpm_list_t
*haystack
, const void *needle
);
67 int alpm_list_find_str(alpm_list_t
*haystack
,const char *needle
);
68 alpm_list_t
*alpm_list_diff(alpm_list_t
*lhs
, alpm_list_t
*rhs
, alpm_list_fn_cmp fn
);
70 #endif /* _ALPM_LIST_H */
72 /* vim: set ts=2 sw=2 noet: */