C Standard Library Extensions  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: not supported by cvs2svn $
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 */
void cx_slist_swap(cx_slist *, cx_slist *)
Swap the data of two lists.
Definition: cxslist.c:858
cxptr cx_slist_pop_front(cx_slist *)
Remove the first list element.
Definition: cxslist.c:1158
void cx_slist_clear(cx_slist *)
Remove all elements from a list.
Definition: cxslist.c:668
cxptr cx_slist_back(const cx_slist *)
Get the last element of a list.
Definition: cxslist.c:942
cx_slist * cx_slist_new(void)
Create a new list without any elements.
Definition: cxslist.c:718
void cx_slist_sort(cx_slist *, cx_compare_func)
Sort all elements of a list using the given comparison function.
Definition: cxslist.c:1397
void cx_slist_remove(cx_slist *, cxcptr)
Remove all elements with a given value from a list.
Definition: cxslist.c:1215
void cx_slist_splice(cx_slist *, cx_slist_iterator, cx_slist *, cx_slist_iterator, cx_slist_iterator)
Move a range of list elements in front of a given position.
Definition: cxslist.c:1303
cxbool cx_slist_empty(const cx_slist *)
Check whether a list is empty.
Definition: cxslist.c:697
void cx_slist_reverse(cx_slist *)
Reverse the order of all list elements.
Definition: cxslist.c:1421
cxptr cx_slist_get(const cx_slist *, cx_slist_const_iterator)
Get the data at a given iterator position.
Definition: cxslist.c:970
void cx_slist_delete(cx_slist *)
Destroy a list.
Definition: cxslist.c:742
cx_slist_iterator cx_slist_begin(const cx_slist *)
Get list iterator to the beginning of a list.
Definition: cxslist.c:588
cx_slist_iterator cx_slist_next(const cx_slist *, cx_slist_const_iterator)
Get a list iterator to the next list element.
Definition: cxslist.c:640
cxsize cx_slist_max_size(const cx_slist *)
Get the maximum number of list elements possible.
Definition: cxslist.c:833
void cx_slist_destroy(cx_slist *, cx_free_func)
Destroy a list and all its elements.
Definition: cxslist.c:770
cxptr cx_slist_assign(cx_slist *, cx_slist_iterator, cxcptr)
Assign data to a list position.
Definition: cxslist.c:887
void cx_slist_unique(cx_slist *, cx_compare_func)
Remove duplicates of consecutive elements.
Definition: cxslist.c:1255
cxptr cx_slist_extract(cx_slist *, cx_slist_iterator)
Extract a list element.
Definition: cxslist.c:1133
cxptr cx_slist_pop_back(cx_slist *)
Remove the last element of a list.
Definition: cxslist.c:1187
cxptr cx_slist_front(const cx_slist *)
Get the first element of a list.
Definition: cxslist.c:918
cx_slist_iterator cx_slist_insert(cx_slist *, cx_slist_iterator, cxcptr)
Insert data into a list at a given iterator position.
Definition: cxslist.c:998
cx_slist_iterator cx_slist_erase(cx_slist *, cx_slist_iterator, cx_free_func)
Erase a list list element.
Definition: cxslist.c:1099
void cx_slist_push_back(cx_slist *, cxcptr)
Append data at the end of a list.
Definition: cxslist.c:1067
void cx_slist_push_front(cx_slist *, cxcptr)
Insert data at the beginning of a list.
Definition: cxslist.c:1037
cxsize cx_slist_size(const cx_slist *)
Get the actual number of list elements.
Definition: cxslist.c:811
cx_slist_iterator cx_slist_end(const cx_slist *)
Get a list iterator to the end of a list.
Definition: cxslist.c:612
void cx_slist_merge(cx_slist *, cx_slist *, cx_compare_func)
Merge two sorted lists.
Definition: cxslist.c:1366