C Standard Library Extensions  1.2.3
cxslist.h
1 /*
2  * This file is part of the ESO C Extension Library
3  * Copyright (C) 2001-2017 European Southern Observatory
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18  */
19 
20 #ifndef CX_SLIST_H
21 #define CX_SLIST_H
22 
23 #include <cxmemory.h>
24 
25 CX_BEGIN_DECLS
26 
27 typedef struct _cx_slnode_ *cx_slist_iterator;
28 typedef const struct _cx_slnode_ *cx_slist_const_iterator;
29 
30 typedef struct _cx_slist_ cx_slist;
31 
32 
33 /*
34  * Create, copy and destroy operations
35  */
36 
37 cx_slist *cx_slist_new(void);
38 void cx_slist_delete(cx_slist *);
39 void cx_slist_destroy(cx_slist *, cx_free_func);
40 
41 /*
42  * Nonmodifying operations
43  */
44 
45 cxsize cx_slist_size(const cx_slist *);
46 cxbool cx_slist_empty(const cx_slist *);
47 cxsize cx_slist_max_size(const cx_slist *);
48 
49 /*
50  * Assignment operations
51  */
52 
53 void cx_slist_swap(cx_slist *, cx_slist *);
54 cxptr cx_slist_assign(cx_slist *, cx_slist_iterator, cxcptr);
55 
56 /*
57  * Element access
58  */
59 
60 cxptr cx_slist_front(const cx_slist *);
61 cxptr cx_slist_back(const cx_slist *);
62 cxptr cx_slist_get(const cx_slist *, cx_slist_const_iterator);
63 
64 /*
65  * Iterator functions
66  */
67 
68 cx_slist_iterator cx_slist_begin(const cx_slist *);
69 cx_slist_iterator cx_slist_end(const cx_slist *);
70 cx_slist_iterator cx_slist_next(const cx_slist *, cx_slist_const_iterator);
71 
72 /*
73  * Inserting and removing elements
74  */
75 
76 void cx_slist_push_front(cx_slist *, cxcptr);
77 cxptr cx_slist_pop_front(cx_slist *);
78 void cx_slist_push_back(cx_slist *, cxcptr);
79 cxptr cx_slist_pop_back(cx_slist *);
80 
81 cx_slist_iterator cx_slist_insert(cx_slist *, cx_slist_iterator, cxcptr);
82 cx_slist_iterator cx_slist_erase(cx_slist *, cx_slist_iterator, cx_free_func);
83 cxptr cx_slist_extract(cx_slist *, cx_slist_iterator);
84 void cx_slist_remove(cx_slist *, cxcptr);
85 void cx_slist_clear(cx_slist *);
86 
87 /*
88  * Splice functions
89  */
90 
91 void cx_slist_unique(cx_slist *, cx_compare_func);
92 void cx_slist_splice(cx_slist *, cx_slist_iterator, cx_slist *,
93  cx_slist_iterator, cx_slist_iterator);
94 void cx_slist_merge(cx_slist *, cx_slist *, cx_compare_func);
95 void cx_slist_sort(cx_slist *, cx_compare_func);
96 void cx_slist_reverse(cx_slist *);
97 
98 CX_END_DECLS
99 
100 #endif /* CX_SLIST_H */
void cx_slist_swap(cx_slist *, cx_slist *)
Swap the data of two lists.
Definition: cxslist.c:850
cxptr cx_slist_pop_front(cx_slist *)
Remove the first list element.
Definition: cxslist.c:1150
void cx_slist_clear(cx_slist *)
Remove all elements from a list.
Definition: cxslist.c:660
cxptr cx_slist_back(const cx_slist *)
Get the last element of a list.
Definition: cxslist.c:934
cx_slist * cx_slist_new(void)
Create a new list without any elements.
Definition: cxslist.c:710
void cx_slist_sort(cx_slist *, cx_compare_func)
Sort all elements of a list using the given comparison function.
Definition: cxslist.c:1389
void cx_slist_remove(cx_slist *, cxcptr)
Remove all elements with a given value from a list.
Definition: cxslist.c:1207
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:1295
cxbool cx_slist_empty(const cx_slist *)
Check whether a list is empty.
Definition: cxslist.c:689
void cx_slist_reverse(cx_slist *)
Reverse the order of all list elements.
Definition: cxslist.c:1413
cxptr cx_slist_get(const cx_slist *, cx_slist_const_iterator)
Get the data at a given iterator position.
Definition: cxslist.c:962
void cx_slist_delete(cx_slist *)
Destroy a list.
Definition: cxslist.c:734
cx_slist_iterator cx_slist_begin(const cx_slist *)
Get list iterator to the beginning of a list.
Definition: cxslist.c:580
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:632
cxsize cx_slist_max_size(const cx_slist *)
Get the maximum number of list elements possible.
Definition: cxslist.c:825
void cx_slist_destroy(cx_slist *, cx_free_func)
Destroy a list and all its elements.
Definition: cxslist.c:762
cxptr cx_slist_assign(cx_slist *, cx_slist_iterator, cxcptr)
Assign data to a list position.
Definition: cxslist.c:879
void cx_slist_unique(cx_slist *, cx_compare_func)
Remove duplicates of consecutive elements.
Definition: cxslist.c:1247
cxptr cx_slist_extract(cx_slist *, cx_slist_iterator)
Extract a list element.
Definition: cxslist.c:1125
cxptr cx_slist_pop_back(cx_slist *)
Remove the last element of a list.
Definition: cxslist.c:1179
cxptr cx_slist_front(const cx_slist *)
Get the first element of a list.
Definition: cxslist.c:910
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:990
cx_slist_iterator cx_slist_erase(cx_slist *, cx_slist_iterator, cx_free_func)
Erase a list list element.
Definition: cxslist.c:1091
void cx_slist_push_back(cx_slist *, cxcptr)
Append data at the end of a list.
Definition: cxslist.c:1059
void cx_slist_push_front(cx_slist *, cxcptr)
Insert data at the beginning of a list.
Definition: cxslist.c:1029
cxsize cx_slist_size(const cx_slist *)
Get the actual number of list elements.
Definition: cxslist.c:803
cx_slist_iterator cx_slist_end(const cx_slist *)
Get a list iterator to the end of a list.
Definition: cxslist.c:604
void cx_slist_merge(cx_slist *, cx_slist *, cx_compare_func)
Merge two sorted lists.
Definition: cxslist.c:1358