C Standard Library Extensions  1.1.2
cxslist.h
1 /* $Id: cxslist.h,v 1.7 2011/02/21 14:15:31 rpalsa Exp $
2  *
3  * This file is part of the ESO C Extension Library
4  * Copyright (C) 2001-2011 European Southern Observatory
5  *
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.
10  *
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.
15  *
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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19  */
20 
21 /*
22  * $Author: rpalsa $
23  * $Date: 2011/02/21 14:15:31 $
24  * $Revision: 1.7 $
25  * $Name: cpl-6_3_1 $
26  */
27 
28 #ifndef CX_SLIST_H
29 #define CX_SLIST_H
30 
31 #include <cxmemory.h>
32 
33 CX_BEGIN_DECLS
34 
35 typedef struct _cx_slnode_ *cx_slist_iterator;
36 typedef const struct _cx_slnode_ *cx_slist_const_iterator;
37 
38 typedef struct _cx_slist_ cx_slist;
39 
40 
41 /*
42  * Create, copy and destroy operations
43  */
44 
45 cx_slist *cx_slist_new(void);
46 void cx_slist_delete(cx_slist *);
47 void cx_slist_destroy(cx_slist *, cx_free_func);
48 
49 /*
50  * Nonmodifying operations
51  */
52 
53 cxsize cx_slist_size(const cx_slist *);
54 cxbool cx_slist_empty(const cx_slist *);
55 cxsize cx_slist_max_size(const cx_slist *);
56 
57 /*
58  * Assignment operations
59  */
60 
61 void cx_slist_swap(cx_slist *, cx_slist *);
62 cxptr cx_slist_assign(cx_slist *, cx_slist_iterator, cxcptr);
63 
64 /*
65  * Element access
66  */
67 
68 cxptr cx_slist_front(const cx_slist *);
69 cxptr cx_slist_back(const cx_slist *);
70 cxptr cx_slist_get(const cx_slist *, cx_slist_const_iterator);
71 
72 /*
73  * Iterator functions
74  */
75 
76 cx_slist_iterator cx_slist_begin(const cx_slist *);
77 cx_slist_iterator cx_slist_end(const cx_slist *);
78 cx_slist_iterator cx_slist_next(const cx_slist *, cx_slist_const_iterator);
79 
80 /*
81  * Inserting and removing elements
82  */
83 
84 void cx_slist_push_front(cx_slist *, cxcptr);
85 cxptr cx_slist_pop_front(cx_slist *);
86 void cx_slist_push_back(cx_slist *, cxcptr);
87 cxptr cx_slist_pop_back(cx_slist *);
88 
89 cx_slist_iterator cx_slist_insert(cx_slist *, cx_slist_iterator, cxcptr);
90 cx_slist_iterator cx_slist_erase(cx_slist *, cx_slist_iterator, cx_free_func);
91 cxptr cx_slist_extract(cx_slist *, cx_slist_iterator);
92 void cx_slist_remove(cx_slist *, cxcptr);
93 void cx_slist_clear(cx_slist *);
94 
95 /*
96  * Splice functions
97  */
98 
99 void cx_slist_unique(cx_slist *, cx_compare_func);
100 void cx_slist_splice(cx_slist *, cx_slist_iterator, cx_slist *,
101  cx_slist_iterator, cx_slist_iterator);
102 void cx_slist_merge(cx_slist *, cx_slist *, cx_compare_func);
103 void cx_slist_sort(cx_slist *, cx_compare_func);
104 void cx_slist_reverse(cx_slist *);
105 
106 CX_END_DECLS
107 
108 #endif /* CX_SLIST_H */