C Standard Library Extensions  1.1.2
cxlist.h
1 /* $Id: cxlist.h,v 1.4 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.4 $
25  * $Name: not supported by cvs2svn $
26  */
27 
28 #ifndef CX_LIST_H
29 #define CX_LIST_H
30 
31 #include <cxmemory.h>
32 
33 CX_BEGIN_DECLS
34 
35 typedef struct _cx_lnode_ *cx_list_iterator;
36 typedef const struct _cx_lnode_ *cx_list_const_iterator;
37 
38 typedef struct _cx_list_ cx_list;
39 
40 
41 /*
42  * Create, copy and destroy operations
43  */
44 
45 cx_list *cx_list_new(void);
46 void cx_list_delete(cx_list *);
47 void cx_list_destroy(cx_list *, cx_free_func);
48 
49 /*
50  * Non-modifying operations
51  */
52 
53 cxsize cx_list_size(const cx_list *);
54 cxbool cx_list_empty(const cx_list *);
55 cxsize cx_list_max_size(const cx_list *);
56 
57 /*
58  * Assignment operations
59  */
60 
61 void cx_list_swap(cx_list *, cx_list *);
62 cxptr cx_list_assign(cx_list *, cx_list_iterator, cxcptr);
63 
64 /*
65  * Element access
66  */
67 
68 cxptr cx_list_front(const cx_list *);
69 cxptr cx_list_back(const cx_list *);
70 cxptr cx_list_get(const cx_list *, cx_list_const_iterator);
71 
72 /*
73  * Iterator functions
74  */
75 
76 cx_list_iterator cx_list_begin(const cx_list *);
77 cx_list_iterator cx_list_end(const cx_list *);
78 cx_list_iterator cx_list_next(const cx_list *, cx_list_const_iterator);
79 cx_list_iterator cx_list_previous(const cx_list *, cx_list_const_iterator);
80 
81 /*
82  * Inserting and removing elements
83  */
84 
85 void cx_list_push_front(cx_list *, cxcptr);
86 cxptr cx_list_pop_front(cx_list *);
87 void cx_list_push_back(cx_list *, cxcptr);
88 cxptr cx_list_pop_back(cx_list *);
89 
90 cx_list_iterator cx_list_insert(cx_list *, cx_list_iterator, cxcptr);
91 cx_list_iterator cx_list_erase(cx_list *, cx_list_iterator, cx_free_func);
92 cxptr cx_list_extract(cx_list *, cx_list_iterator);
93 void cx_list_remove(cx_list *, cxcptr);
94 void cx_list_clear(cx_list *);
95 
96 /*
97  * Splice functions
98  */
99 
100 void cx_list_unique(cx_list *, cx_compare_func);
101 void cx_list_splice(cx_list *, cx_list_iterator, cx_list *,
102  cx_list_iterator, cx_list_iterator);
103 void cx_list_merge(cx_list *, cx_list *, cx_compare_func);
104 void cx_list_sort(cx_list *, cx_compare_func);
105 void cx_list_reverse(cx_list *);
106 
107 CX_END_DECLS
108 
109 #endif /* CX_LIST_H */
void cx_list_delete(cx_list *)
Destroy a list.
Definition: cxlist.c:728
void cx_list_reverse(cx_list *)
Reverse the order of all list elements.
Definition: cxlist.c:1433
void cx_list_merge(cx_list *, cx_list *, cx_compare_func)
Merge two sorted lists.
Definition: cxlist.c:1378
cx_list_iterator cx_list_insert(cx_list *, cx_list_iterator, cxcptr)
Insert data into a list at a given iterator position.
Definition: cxlist.c:1000
void cx_list_swap(cx_list *, cx_list *)
Swap the data of two lists.
Definition: cxlist.c:842
void cx_list_sort(cx_list *, cx_compare_func)
Sort all elements of a list using the given comparison function.
Definition: cxlist.c:1409
cxsize cx_list_size(const cx_list *)
Get the actual number of list elements.
Definition: cxlist.c:795
cx_list_iterator cx_list_next(const cx_list *, cx_list_const_iterator)
Get an iterator for the next list element.
Definition: cxlist.c:600
cx_list_iterator cx_list_previous(const cx_list *, cx_list_const_iterator)
Get an iterator for the previous list element.
Definition: cxlist.c:628
cxptr cx_list_front(const cx_list *)
Get the first element of a list.
Definition: cxlist.c:919
void cx_list_splice(cx_list *, cx_list_iterator, cx_list *, cx_list_iterator, cx_list_iterator)
Move a range of list elements in front of a given position.
Definition: cxlist.c:1326
void cx_list_destroy(cx_list *, cx_free_func)
Destroy a list and all its elements.
Definition: cxlist.c:756
cx_list_iterator cx_list_erase(cx_list *, cx_list_iterator, cx_free_func)
Erase a list element.
Definition: cxlist.c:1096
cx_list_iterator cx_list_end(const cx_list *)
Get an iterator for the position after the last list element.
Definition: cxlist.c:574
cxsize cx_list_max_size(const cx_list *)
Get the maximum number of list elements possible.
Definition: cxlist.c:817
void cx_list_remove(cx_list *, cxcptr)
Remove all elements with a given value from a list.
Definition: cxlist.c:1229
cxptr cx_list_get(const cx_list *, cx_list_const_iterator)
Get the data at a given iterator position.
Definition: cxlist.c:972
cxptr cx_list_assign(cx_list *, cx_list_iterator, cxcptr)
Assign data to a list element.
Definition: cxlist.c:885
cx_list * cx_list_new(void)
Create a new list without any elements.
Definition: cxlist.c:704
cxptr cx_list_back(const cx_list *)
Get the last element of a list.
Definition: cxlist.c:947
void cx_list_unique(cx_list *, cx_compare_func)
Remove duplicates of consecutive elements.
Definition: cxlist.c:1273
cxptr cx_list_pop_back(cx_list *)
Remove the last element of a list.
Definition: cxlist.c:1199
void cx_list_push_front(cx_list *, cxcptr)
Insert data at the beginning of a list.
Definition: cxlist.c:1039
cx_list_iterator cx_list_begin(const cx_list *)
Get an iterator for the first list element.
Definition: cxlist.c:550
cxbool cx_list_empty(const cx_list *)
Check whether a list is empty.
Definition: cxlist.c:683
void cx_list_push_back(cx_list *, cxcptr)
Append data at the end of a list.
Definition: cxlist.c:1069
void cx_list_clear(cx_list *)
Remove all elements from a list.
Definition: cxlist.c:656
cxptr cx_list_extract(cx_list *, cx_list_iterator)
Extract a list element.
Definition: cxlist.c:1131
cxptr cx_list_pop_front(cx_list *)
Remove the first list element.
Definition: cxlist.c:1167