Mercurial > hg > octave-shane > gnulib-hg
annotate lib/gl_list.h @ 15727:144db791c6fa
Ensure EBADF returns for socket functions on mingw.
* lib/accept.c (rpl_accept): Fail with error EBADF if the file
descriptor is invalid.
* lib/bind.c (rpl_bind): Likewise.
* lib/connect.c (rpl_connect): Likewise.
* lib/getpeername.c (rpl_getpeername): Likewise.
* lib/getsockname.c (rpl_getsockname): Likewise.
* lib/getsockopt.c (rpl_getsockopt): Likewise.
* lib/listen.c (rpl_listen): Likewise.
* lib/recv.c (rpl_recv): Likewise.
* lib/recvfrom.c (rpl_recvfrom): Likewise.
* lib/send.c (rpl_send): Likewise.
* lib/sendto.c (rpl_sendto): Likewise.
* lib/setsockopt.c (rpl_setsockopt): Likewise.
* lib/shutdown.c (rpl_shutdown): Likewise.
author | Bruno Haible <bruno@clisp.org> |
---|---|
date | Wed, 21 Sep 2011 00:20:59 +0200 |
parents | 97fc9a21a8fb |
children | 8250f2777afc |
rev | line source |
---|---|
6984 | 1 /* Abstract sequential list data type. |
14079
97fc9a21a8fb
maint: update almost all copyright ranges to include 2011
Jim Meyering <meyering@redhat.com>
parents:
12559
diff
changeset
|
2 Copyright (C) 2006-2011 Free Software Foundation, Inc. |
6984 | 3 Written by Bruno Haible <bruno@clisp.org>, 2006. |
4 | |
9309
bbbbbf4cd1c5
Change copyright notice from GPLv2+ to GPLv3+.
Bruno Haible <bruno@clisp.org>
parents:
8438
diff
changeset
|
5 This program is free software: you can redistribute it and/or modify |
6984 | 6 it under the terms of the GNU General Public License as published by |
9309
bbbbbf4cd1c5
Change copyright notice from GPLv2+ to GPLv3+.
Bruno Haible <bruno@clisp.org>
parents:
8438
diff
changeset
|
7 the Free Software Foundation; either version 3 of the License, or |
bbbbbf4cd1c5
Change copyright notice from GPLv2+ to GPLv3+.
Bruno Haible <bruno@clisp.org>
parents:
8438
diff
changeset
|
8 (at your option) any later version. |
6984 | 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 | |
9309
bbbbbf4cd1c5
Change copyright notice from GPLv2+ to GPLv3+.
Bruno Haible <bruno@clisp.org>
parents:
8438
diff
changeset
|
16 along with this program. If not, see <http://www.gnu.org/licenses/>. */ |
6984 | 17 |
18 #ifndef _GL_LIST_H | |
19 #define _GL_LIST_H | |
20 | |
21 #include <stdbool.h> | |
22 #include <stddef.h> | |
23 | |
24 #ifdef __cplusplus | |
25 extern "C" { | |
26 #endif | |
27 | |
28 | |
29 /* gl_list is an abstract list data type. It can contain any number of | |
30 objects ('void *' or 'const void *' pointers) in any given order. | |
31 Duplicates are allowed, but can optionally be forbidden. | |
32 | |
33 There are several implementations of this list datatype, optimized for | |
34 different operations or for memory. You can start using the simplest list | |
35 implementation, GL_ARRAY_LIST, and switch to a different implementation | |
36 later, when you realize which operations are performed the most frequently. | |
37 The API of the different implementations is exactly the same; when | |
38 switching to a different implementation, you only have to change the | |
39 gl_list_create call. | |
40 | |
41 The implementations are: | |
42 GL_ARRAY_LIST a growable array | |
43 GL_CARRAY_LIST a growable circular array | |
44 GL_LINKED_LIST a linked list | |
45 GL_AVLTREE_LIST a binary tree (AVL tree) | |
46 GL_RBTREE_LIST a binary tree (red-black tree) | |
47 GL_LINKEDHASH_LIST a hash table with a linked list | |
48 GL_AVLTREEHASH_LIST a hash table with a binary tree (AVL tree) | |
49 GL_RBTREEHASH_LIST a hash table with a binary tree (red-black tree) | |
50 | |
51 The memory consumption is asymptotically the same: O(1) for every object | |
52 in the list. When looking more closely at the average memory consumed | |
53 for an object, GL_ARRAY_LIST is the most compact representation, and | |
54 GL_LINKEDHASH_LIST and GL_TREEHASH_LIST need more memory. | |
55 | |
56 The guaranteed average performance of the operations is, for a list of | |
57 n elements: | |
58 | |
59 Operation ARRAY LINKED TREE LINKEDHASH TREEHASH | |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12081
diff
changeset
|
60 CARRAY with|without with|without |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12081
diff
changeset
|
61 duplicates duplicates |
6984 | 62 |
63 gl_list_size O(1) O(1) O(1) O(1) O(1) | |
64 gl_list_node_value O(1) O(1) O(1) O(1) O(1) | |
9686
25f7280c9cf0
New abstract list operation 'node_set_value'.
Bruno Haible <bruno@clisp.org>
parents:
9309
diff
changeset
|
65 gl_list_node_set_value O(1) O(1) O(1) O(1) O((log n)²)/O(1) |
6984 | 66 gl_list_next_node O(1) O(1) O(log n) O(1) O(log n) |
67 gl_list_previous_node O(1) O(1) O(log n) O(1) O(log n) | |
68 gl_list_get_at O(1) O(n) O(log n) O(n) O(log n) | |
69 gl_list_set_at O(1) O(n) O(log n) O(n) O((log n)²)/O(log n) | |
70 gl_list_search O(n) O(n) O(n) O(n)/O(1) O(log n)/O(1) | |
7405
0de49c40e105
Add searching operations, limited to a subsequence of the list.
Bruno Haible <bruno@clisp.org>
parents:
6984
diff
changeset
|
71 gl_list_search_from O(n) O(n) O(n) O(n)/O(1) O((log n)²)/O(log n) |
0de49c40e105
Add searching operations, limited to a subsequence of the list.
Bruno Haible <bruno@clisp.org>
parents:
6984
diff
changeset
|
72 gl_list_search_from_to O(n) O(n) O(n) O(n)/O(1) O((log n)²)/O(log n) |
6984 | 73 gl_list_indexof O(n) O(n) O(n) O(n) O(log n) |
7405
0de49c40e105
Add searching operations, limited to a subsequence of the list.
Bruno Haible <bruno@clisp.org>
parents:
6984
diff
changeset
|
74 gl_list_indexof_from O(n) O(n) O(n) O(n) O((log n)²)/O(log n) |
0de49c40e105
Add searching operations, limited to a subsequence of the list.
Bruno Haible <bruno@clisp.org>
parents:
6984
diff
changeset
|
75 gl_list_indexof_from_to O(n) O(n) O(n) O(n) O((log n)²)/O(log n) |
6984 | 76 gl_list_add_first O(n)/O(1) O(1) O(log n) O(1) O((log n)²)/O(log n) |
77 gl_list_add_last O(1) O(1) O(log n) O(1) O((log n)²)/O(log n) | |
78 gl_list_add_before O(n) O(1) O(log n) O(1) O((log n)²)/O(log n) | |
79 gl_list_add_after O(n) O(1) O(log n) O(1) O((log n)²)/O(log n) | |
80 gl_list_add_at O(n) O(n) O(log n) O(n) O((log n)²)/O(log n) | |
81 gl_list_remove_node O(n) O(1) O(log n) O(n)/O(1) O((log n)²)/O(log n) | |
82 gl_list_remove_at O(n) O(n) O(log n) O(n) O((log n)²)/O(log n) | |
83 gl_list_remove O(n) O(n) O(n) O(n)/O(1) O((log n)²)/O(log n) | |
84 gl_list_iterator O(1) O(1) O(log n) O(1) O(log n) | |
85 gl_list_iterator_from_to O(1) O(n) O(log n) O(n) O(log n) | |
86 gl_list_iterator_next O(1) O(1) O(log n) O(1) O(log n) | |
87 gl_sortedlist_search O(log n) O(n) O(log n) O(n) O(log n) | |
7410
9704ff2cbdfe
Add bounded list search operations.
Bruno Haible <bruno@clisp.org>
parents:
7405
diff
changeset
|
88 gl_sortedlist_search_from O(log n) O(n) O(log n) O(n) O(log n) |
6984 | 89 gl_sortedlist_indexof O(log n) O(n) O(log n) O(n) O(log n) |
7410
9704ff2cbdfe
Add bounded list search operations.
Bruno Haible <bruno@clisp.org>
parents:
7405
diff
changeset
|
90 gl_sortedlist_indexof_fro O(log n) O(n) O(log n) O(n) O(log n) |
6984 | 91 gl_sortedlist_add O(n) O(n) O(log n) O(n) O((log n)²)/O(log n) |
92 gl_sortedlist_remove O(n) O(n) O(log n) O(n) O((log n)²)/O(log n) | |
93 */ | |
94 | |
95 /* -------------------------- gl_list_t Data Type -------------------------- */ | |
96 | |
97 /* Type of function used to compare two elements. | |
98 NULL denotes pointer comparison. */ | |
99 typedef bool (*gl_listelement_equals_fn) (const void *elt1, const void *elt2); | |
100 | |
101 /* Type of function used to compute a hash code. | |
102 NULL denotes a function that depends only on the pointer itself. */ | |
103 typedef size_t (*gl_listelement_hashcode_fn) (const void *elt); | |
104 | |
8438
238942284e2f
Allow the use of a destructor for the values stored in the list.
Bruno Haible <bruno@clisp.org>
parents:
7554
diff
changeset
|
105 /* Type of function used to dispose an element once it's removed from a list. |
238942284e2f
Allow the use of a destructor for the values stored in the list.
Bruno Haible <bruno@clisp.org>
parents:
7554
diff
changeset
|
106 NULL denotes a no-op. */ |
238942284e2f
Allow the use of a destructor for the values stored in the list.
Bruno Haible <bruno@clisp.org>
parents:
7554
diff
changeset
|
107 typedef void (*gl_listelement_dispose_fn) (const void *elt); |
238942284e2f
Allow the use of a destructor for the values stored in the list.
Bruno Haible <bruno@clisp.org>
parents:
7554
diff
changeset
|
108 |
6984 | 109 struct gl_list_impl; |
110 /* Type representing an entire list. */ | |
111 typedef struct gl_list_impl * gl_list_t; | |
112 | |
113 struct gl_list_node_impl; | |
114 /* Type representing the position of an element in the list, in a way that | |
115 is more adapted to the list implementation than a plain index. | |
116 Note: It is invalidated by insertions and removals! */ | |
117 typedef struct gl_list_node_impl * gl_list_node_t; | |
118 | |
119 struct gl_list_implementation; | |
120 /* Type representing a list datatype implementation. */ | |
121 typedef const struct gl_list_implementation * gl_list_implementation_t; | |
122 | |
123 /* Create an empty list. | |
124 IMPLEMENTATION is one of GL_ARRAY_LIST, GL_CARRAY_LIST, GL_LINKED_LIST, | |
125 GL_AVLTREE_LIST, GL_RBTREE_LIST, GL_LINKEDHASH_LIST, GL_AVLTREEHASH_LIST, | |
126 GL_RBTREEHASH_LIST. | |
127 EQUALS_FN is an element comparison function or NULL. | |
128 HASHCODE_FN is an element hash code function or NULL. | |
8438
238942284e2f
Allow the use of a destructor for the values stored in the list.
Bruno Haible <bruno@clisp.org>
parents:
7554
diff
changeset
|
129 DISPOSE_FN is an element disposal function or NULL. |
6984 | 130 ALLOW_DUPLICATES is false if duplicate elements shall not be allowed in |
131 the list. The implementation may verify this at runtime. */ | |
12445
a8c91b846640
Move the malloc checking from module 'list' to new module 'xlist'.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
132 #if 0 /* declared in gl_xlist.h */ |
6984 | 133 extern gl_list_t gl_list_create_empty (gl_list_implementation_t implementation, |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12081
diff
changeset
|
134 gl_listelement_equals_fn equals_fn, |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12081
diff
changeset
|
135 gl_listelement_hashcode_fn hashcode_fn, |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12081
diff
changeset
|
136 gl_listelement_dispose_fn dispose_fn, |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12081
diff
changeset
|
137 bool allow_duplicates); |
12445
a8c91b846640
Move the malloc checking from module 'list' to new module 'xlist'.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
138 #endif |
a8c91b846640
Move the malloc checking from module 'list' to new module 'xlist'.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
139 /* Likewise. Return NULL upon out-of-memory. */ |
a8c91b846640
Move the malloc checking from module 'list' to new module 'xlist'.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
140 extern gl_list_t gl_list_nx_create_empty (gl_list_implementation_t implementation, |
a8c91b846640
Move the malloc checking from module 'list' to new module 'xlist'.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
141 gl_listelement_equals_fn equals_fn, |
a8c91b846640
Move the malloc checking from module 'list' to new module 'xlist'.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
142 gl_listelement_hashcode_fn hashcode_fn, |
a8c91b846640
Move the malloc checking from module 'list' to new module 'xlist'.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
143 gl_listelement_dispose_fn dispose_fn, |
a8c91b846640
Move the malloc checking from module 'list' to new module 'xlist'.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
144 bool allow_duplicates); |
6984 | 145 |
146 /* Create a list with given contents. | |
147 IMPLEMENTATION is one of GL_ARRAY_LIST, GL_CARRAY_LIST, GL_LINKED_LIST, | |
148 GL_AVLTREE_LIST, GL_RBTREE_LIST, GL_LINKEDHASH_LIST, GL_AVLTREEHASH_LIST, | |
149 GL_RBTREEHASH_LIST. | |
150 EQUALS_FN is an element comparison function or NULL. | |
151 HASHCODE_FN is an element hash code function or NULL. | |
8438
238942284e2f
Allow the use of a destructor for the values stored in the list.
Bruno Haible <bruno@clisp.org>
parents:
7554
diff
changeset
|
152 DISPOSE_FN is an element disposal function or NULL. |
6984 | 153 ALLOW_DUPLICATES is false if duplicate elements shall not be allowed in |
154 the list. The implementation may verify this at runtime. | |
155 COUNT is the number of initial elements. | |
156 CONTENTS[0..COUNT-1] is the initial contents. */ | |
12445
a8c91b846640
Move the malloc checking from module 'list' to new module 'xlist'.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
157 #if 0 /* declared in gl_xlist.h */ |
6984 | 158 extern gl_list_t gl_list_create (gl_list_implementation_t implementation, |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12081
diff
changeset
|
159 gl_listelement_equals_fn equals_fn, |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12081
diff
changeset
|
160 gl_listelement_hashcode_fn hashcode_fn, |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12081
diff
changeset
|
161 gl_listelement_dispose_fn dispose_fn, |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12081
diff
changeset
|
162 bool allow_duplicates, |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12081
diff
changeset
|
163 size_t count, const void **contents); |
12445
a8c91b846640
Move the malloc checking from module 'list' to new module 'xlist'.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
164 #endif |
a8c91b846640
Move the malloc checking from module 'list' to new module 'xlist'.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
165 /* Likewise. Return NULL upon out-of-memory. */ |
a8c91b846640
Move the malloc checking from module 'list' to new module 'xlist'.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
166 extern gl_list_t gl_list_nx_create (gl_list_implementation_t implementation, |
a8c91b846640
Move the malloc checking from module 'list' to new module 'xlist'.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
167 gl_listelement_equals_fn equals_fn, |
a8c91b846640
Move the malloc checking from module 'list' to new module 'xlist'.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
168 gl_listelement_hashcode_fn hashcode_fn, |
a8c91b846640
Move the malloc checking from module 'list' to new module 'xlist'.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
169 gl_listelement_dispose_fn dispose_fn, |
a8c91b846640
Move the malloc checking from module 'list' to new module 'xlist'.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
170 bool allow_duplicates, |
a8c91b846640
Move the malloc checking from module 'list' to new module 'xlist'.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
171 size_t count, const void **contents); |
6984 | 172 |
173 /* Return the current number of elements in a list. */ | |
174 extern size_t gl_list_size (gl_list_t list); | |
175 | |
176 /* Return the element value represented by a list node. */ | |
177 extern const void * gl_list_node_value (gl_list_t list, gl_list_node_t node); | |
178 | |
9686
25f7280c9cf0
New abstract list operation 'node_set_value'.
Bruno Haible <bruno@clisp.org>
parents:
9309
diff
changeset
|
179 /* Replace the element value represented by a list node. */ |
12445
a8c91b846640
Move the malloc checking from module 'list' to new module 'xlist'.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
180 #if 0 /* declared in gl_xlist.h */ |
9686
25f7280c9cf0
New abstract list operation 'node_set_value'.
Bruno Haible <bruno@clisp.org>
parents:
9309
diff
changeset
|
181 extern void gl_list_node_set_value (gl_list_t list, gl_list_node_t node, |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12081
diff
changeset
|
182 const void *elt); |
12445
a8c91b846640
Move the malloc checking from module 'list' to new module 'xlist'.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
183 #endif |
a8c91b846640
Move the malloc checking from module 'list' to new module 'xlist'.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
184 /* Likewise. Return 0 upon success, -1 upon out-of-memory. */ |
a8c91b846640
Move the malloc checking from module 'list' to new module 'xlist'.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
185 extern int gl_list_node_nx_set_value (gl_list_t list, gl_list_node_t node, |
a8c91b846640
Move the malloc checking from module 'list' to new module 'xlist'.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
186 const void *elt) |
a8c91b846640
Move the malloc checking from module 'list' to new module 'xlist'.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
187 #if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) |
a8c91b846640
Move the malloc checking from module 'list' to new module 'xlist'.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
188 __attribute__ ((__warn_unused_result__)) |
a8c91b846640
Move the malloc checking from module 'list' to new module 'xlist'.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
189 #endif |
a8c91b846640
Move the malloc checking from module 'list' to new module 'xlist'.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
190 ; |
9686
25f7280c9cf0
New abstract list operation 'node_set_value'.
Bruno Haible <bruno@clisp.org>
parents:
9309
diff
changeset
|
191 |
6984 | 192 /* Return the node immediately after the given node in the list, or NULL |
193 if the given node is the last (rightmost) one in the list. */ | |
194 extern gl_list_node_t gl_list_next_node (gl_list_t list, gl_list_node_t node); | |
195 | |
196 /* Return the node immediately before the given node in the list, or NULL | |
197 if the given node is the first (leftmost) one in the list. */ | |
198 extern gl_list_node_t gl_list_previous_node (gl_list_t list, gl_list_node_t node); | |
199 | |
200 /* Return the element at a given position in the list. | |
201 POSITION must be >= 0 and < gl_list_size (list). */ | |
202 extern const void * gl_list_get_at (gl_list_t list, size_t position); | |
203 | |
204 /* Replace the element at a given position in the list. | |
205 POSITION must be >= 0 and < gl_list_size (list). | |
206 Return its node. */ | |
12445
a8c91b846640
Move the malloc checking from module 'list' to new module 'xlist'.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
207 #if 0 /* declared in gl_xlist.h */ |
6984 | 208 extern gl_list_node_t gl_list_set_at (gl_list_t list, size_t position, |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12081
diff
changeset
|
209 const void *elt); |
12445
a8c91b846640
Move the malloc checking from module 'list' to new module 'xlist'.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
210 #endif |
a8c91b846640
Move the malloc checking from module 'list' to new module 'xlist'.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
211 /* Likewise. Return NULL upon out-of-memory. */ |
a8c91b846640
Move the malloc checking from module 'list' to new module 'xlist'.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
212 extern gl_list_node_t gl_list_nx_set_at (gl_list_t list, size_t position, |
a8c91b846640
Move the malloc checking from module 'list' to new module 'xlist'.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
213 const void *elt) |
a8c91b846640
Move the malloc checking from module 'list' to new module 'xlist'.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
214 #if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) |
a8c91b846640
Move the malloc checking from module 'list' to new module 'xlist'.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
215 __attribute__ ((__warn_unused_result__)) |
a8c91b846640
Move the malloc checking from module 'list' to new module 'xlist'.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
216 #endif |
a8c91b846640
Move the malloc checking from module 'list' to new module 'xlist'.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
217 ; |
6984 | 218 |
219 /* Search whether an element is already in the list. | |
220 Return its node if found, or NULL if not present in the list. */ | |
221 extern gl_list_node_t gl_list_search (gl_list_t list, const void *elt); | |
222 | |
7405
0de49c40e105
Add searching operations, limited to a subsequence of the list.
Bruno Haible <bruno@clisp.org>
parents:
6984
diff
changeset
|
223 /* Search whether an element is already in the list, |
0de49c40e105
Add searching operations, limited to a subsequence of the list.
Bruno Haible <bruno@clisp.org>
parents:
6984
diff
changeset
|
224 at a position >= START_INDEX. |
0de49c40e105
Add searching operations, limited to a subsequence of the list.
Bruno Haible <bruno@clisp.org>
parents:
6984
diff
changeset
|
225 Return its node if found, or NULL if not present in the list. */ |
0de49c40e105
Add searching operations, limited to a subsequence of the list.
Bruno Haible <bruno@clisp.org>
parents:
6984
diff
changeset
|
226 extern gl_list_node_t gl_list_search_from (gl_list_t list, size_t start_index, |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12081
diff
changeset
|
227 const void *elt); |
7405
0de49c40e105
Add searching operations, limited to a subsequence of the list.
Bruno Haible <bruno@clisp.org>
parents:
6984
diff
changeset
|
228 |
0de49c40e105
Add searching operations, limited to a subsequence of the list.
Bruno Haible <bruno@clisp.org>
parents:
6984
diff
changeset
|
229 /* Search whether an element is already in the list, |
0de49c40e105
Add searching operations, limited to a subsequence of the list.
Bruno Haible <bruno@clisp.org>
parents:
6984
diff
changeset
|
230 at a position >= START_INDEX and < END_INDEX. |
0de49c40e105
Add searching operations, limited to a subsequence of the list.
Bruno Haible <bruno@clisp.org>
parents:
6984
diff
changeset
|
231 Return its node if found, or NULL if not present in the list. */ |
0de49c40e105
Add searching operations, limited to a subsequence of the list.
Bruno Haible <bruno@clisp.org>
parents:
6984
diff
changeset
|
232 extern gl_list_node_t gl_list_search_from_to (gl_list_t list, |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12081
diff
changeset
|
233 size_t start_index, |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12081
diff
changeset
|
234 size_t end_index, |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12081
diff
changeset
|
235 const void *elt); |
7405
0de49c40e105
Add searching operations, limited to a subsequence of the list.
Bruno Haible <bruno@clisp.org>
parents:
6984
diff
changeset
|
236 |
6984 | 237 /* Search whether an element is already in the list. |
238 Return its position if found, or (size_t)(-1) if not present in the list. */ | |
239 extern size_t gl_list_indexof (gl_list_t list, const void *elt); | |
240 | |
7405
0de49c40e105
Add searching operations, limited to a subsequence of the list.
Bruno Haible <bruno@clisp.org>
parents:
6984
diff
changeset
|
241 /* Search whether an element is already in the list, |
0de49c40e105
Add searching operations, limited to a subsequence of the list.
Bruno Haible <bruno@clisp.org>
parents:
6984
diff
changeset
|
242 at a position >= START_INDEX. |
0de49c40e105
Add searching operations, limited to a subsequence of the list.
Bruno Haible <bruno@clisp.org>
parents:
6984
diff
changeset
|
243 Return its position if found, or (size_t)(-1) if not present in the list. */ |
0de49c40e105
Add searching operations, limited to a subsequence of the list.
Bruno Haible <bruno@clisp.org>
parents:
6984
diff
changeset
|
244 extern size_t gl_list_indexof_from (gl_list_t list, size_t start_index, |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12081
diff
changeset
|
245 const void *elt); |
7405
0de49c40e105
Add searching operations, limited to a subsequence of the list.
Bruno Haible <bruno@clisp.org>
parents:
6984
diff
changeset
|
246 |
0de49c40e105
Add searching operations, limited to a subsequence of the list.
Bruno Haible <bruno@clisp.org>
parents:
6984
diff
changeset
|
247 /* Search whether an element is already in the list, |
0de49c40e105
Add searching operations, limited to a subsequence of the list.
Bruno Haible <bruno@clisp.org>
parents:
6984
diff
changeset
|
248 at a position >= START_INDEX and < END_INDEX. |
0de49c40e105
Add searching operations, limited to a subsequence of the list.
Bruno Haible <bruno@clisp.org>
parents:
6984
diff
changeset
|
249 Return its position if found, or (size_t)(-1) if not present in the list. */ |
0de49c40e105
Add searching operations, limited to a subsequence of the list.
Bruno Haible <bruno@clisp.org>
parents:
6984
diff
changeset
|
250 extern size_t gl_list_indexof_from_to (gl_list_t list, |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12081
diff
changeset
|
251 size_t start_index, size_t end_index, |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12081
diff
changeset
|
252 const void *elt); |
7405
0de49c40e105
Add searching operations, limited to a subsequence of the list.
Bruno Haible <bruno@clisp.org>
parents:
6984
diff
changeset
|
253 |
6984 | 254 /* Add an element as the first element of the list. |
255 Return its node. */ | |
12445
a8c91b846640
Move the malloc checking from module 'list' to new module 'xlist'.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
256 #if 0 /* declared in gl_xlist.h */ |
6984 | 257 extern gl_list_node_t gl_list_add_first (gl_list_t list, const void *elt); |
12445
a8c91b846640
Move the malloc checking from module 'list' to new module 'xlist'.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
258 #endif |
a8c91b846640
Move the malloc checking from module 'list' to new module 'xlist'.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
259 /* Likewise. Return NULL upon out-of-memory. */ |
a8c91b846640
Move the malloc checking from module 'list' to new module 'xlist'.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
260 extern gl_list_node_t gl_list_nx_add_first (gl_list_t list, const void *elt) |
a8c91b846640
Move the malloc checking from module 'list' to new module 'xlist'.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
261 #if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) |
a8c91b846640
Move the malloc checking from module 'list' to new module 'xlist'.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
262 __attribute__ ((__warn_unused_result__)) |
a8c91b846640
Move the malloc checking from module 'list' to new module 'xlist'.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
263 #endif |
a8c91b846640
Move the malloc checking from module 'list' to new module 'xlist'.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
264 ; |
6984 | 265 |
266 /* Add an element as the last element of the list. | |
267 Return its node. */ | |
12445
a8c91b846640
Move the malloc checking from module 'list' to new module 'xlist'.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
268 #if 0 /* declared in gl_xlist.h */ |
6984 | 269 extern gl_list_node_t gl_list_add_last (gl_list_t list, const void *elt); |
12445
a8c91b846640
Move the malloc checking from module 'list' to new module 'xlist'.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
270 #endif |
a8c91b846640
Move the malloc checking from module 'list' to new module 'xlist'.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
271 /* Likewise. Return NULL upon out-of-memory. */ |
a8c91b846640
Move the malloc checking from module 'list' to new module 'xlist'.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
272 extern gl_list_node_t gl_list_nx_add_last (gl_list_t list, const void *elt) |
a8c91b846640
Move the malloc checking from module 'list' to new module 'xlist'.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
273 #if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) |
a8c91b846640
Move the malloc checking from module 'list' to new module 'xlist'.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
274 __attribute__ ((__warn_unused_result__)) |
a8c91b846640
Move the malloc checking from module 'list' to new module 'xlist'.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
275 #endif |
a8c91b846640
Move the malloc checking from module 'list' to new module 'xlist'.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
276 ; |
6984 | 277 |
278 /* Add an element before a given element node of the list. | |
279 Return its node. */ | |
12445
a8c91b846640
Move the malloc checking from module 'list' to new module 'xlist'.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
280 #if 0 /* declared in gl_xlist.h */ |
6984 | 281 extern gl_list_node_t gl_list_add_before (gl_list_t list, gl_list_node_t node, |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12081
diff
changeset
|
282 const void *elt); |
12445
a8c91b846640
Move the malloc checking from module 'list' to new module 'xlist'.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
283 #endif |
a8c91b846640
Move the malloc checking from module 'list' to new module 'xlist'.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
284 /* Likewise. Return NULL upon out-of-memory. */ |
a8c91b846640
Move the malloc checking from module 'list' to new module 'xlist'.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
285 extern gl_list_node_t gl_list_nx_add_before (gl_list_t list, |
a8c91b846640
Move the malloc checking from module 'list' to new module 'xlist'.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
286 gl_list_node_t node, |
a8c91b846640
Move the malloc checking from module 'list' to new module 'xlist'.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
287 const void *elt) |
a8c91b846640
Move the malloc checking from module 'list' to new module 'xlist'.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
288 #if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) |
a8c91b846640
Move the malloc checking from module 'list' to new module 'xlist'.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
289 __attribute__ ((__warn_unused_result__)) |
a8c91b846640
Move the malloc checking from module 'list' to new module 'xlist'.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
290 #endif |
a8c91b846640
Move the malloc checking from module 'list' to new module 'xlist'.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
291 ; |
6984 | 292 |
293 /* Add an element after a given element node of the list. | |
294 Return its node. */ | |
12445
a8c91b846640
Move the malloc checking from module 'list' to new module 'xlist'.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
295 #if 0 /* declared in gl_xlist.h */ |
6984 | 296 extern gl_list_node_t gl_list_add_after (gl_list_t list, gl_list_node_t node, |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12081
diff
changeset
|
297 const void *elt); |
12445
a8c91b846640
Move the malloc checking from module 'list' to new module 'xlist'.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
298 #endif |
a8c91b846640
Move the malloc checking from module 'list' to new module 'xlist'.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
299 /* Likewise. Return NULL upon out-of-memory. */ |
a8c91b846640
Move the malloc checking from module 'list' to new module 'xlist'.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
300 extern gl_list_node_t gl_list_nx_add_after (gl_list_t list, gl_list_node_t node, |
a8c91b846640
Move the malloc checking from module 'list' to new module 'xlist'.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
301 const void *elt) |
a8c91b846640
Move the malloc checking from module 'list' to new module 'xlist'.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
302 #if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) |
a8c91b846640
Move the malloc checking from module 'list' to new module 'xlist'.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
303 __attribute__ ((__warn_unused_result__)) |
a8c91b846640
Move the malloc checking from module 'list' to new module 'xlist'.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
304 #endif |
a8c91b846640
Move the malloc checking from module 'list' to new module 'xlist'.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
305 ; |
6984 | 306 |
12458 | 307 /* Add an element at a given position in the list. |
6984 | 308 POSITION must be >= 0 and <= gl_list_size (list). */ |
12445
a8c91b846640
Move the malloc checking from module 'list' to new module 'xlist'.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
309 #if 0 /* declared in gl_xlist.h */ |
6984 | 310 extern gl_list_node_t gl_list_add_at (gl_list_t list, size_t position, |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12081
diff
changeset
|
311 const void *elt); |
12445
a8c91b846640
Move the malloc checking from module 'list' to new module 'xlist'.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
312 #endif |
a8c91b846640
Move the malloc checking from module 'list' to new module 'xlist'.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
313 /* Likewise. Return NULL upon out-of-memory. */ |
a8c91b846640
Move the malloc checking from module 'list' to new module 'xlist'.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
314 extern gl_list_node_t gl_list_nx_add_at (gl_list_t list, size_t position, |
a8c91b846640
Move the malloc checking from module 'list' to new module 'xlist'.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
315 const void *elt) |
a8c91b846640
Move the malloc checking from module 'list' to new module 'xlist'.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
316 #if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) |
a8c91b846640
Move the malloc checking from module 'list' to new module 'xlist'.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
317 __attribute__ ((__warn_unused_result__)) |
a8c91b846640
Move the malloc checking from module 'list' to new module 'xlist'.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
318 #endif |
a8c91b846640
Move the malloc checking from module 'list' to new module 'xlist'.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
319 ; |
6984 | 320 |
321 /* Remove an element from the list. | |
322 Return true. */ | |
323 extern bool gl_list_remove_node (gl_list_t list, gl_list_node_t node); | |
324 | |
325 /* Remove an element at a given position from the list. | |
326 POSITION must be >= 0 and < gl_list_size (list). | |
327 Return true. */ | |
328 extern bool gl_list_remove_at (gl_list_t list, size_t position); | |
329 | |
330 /* Search and remove an element from the list. | |
331 Return true if it was found and removed. */ | |
332 extern bool gl_list_remove (gl_list_t list, const void *elt); | |
333 | |
334 /* Free an entire list. | |
335 (But this call does not free the elements of the list.) */ | |
336 extern void gl_list_free (gl_list_t list); | |
337 | |
338 /* --------------------- gl_list_iterator_t Data Type --------------------- */ | |
339 | |
340 /* Functions for iterating through a list. */ | |
341 | |
342 /* Type of an iterator that traverses a list. | |
343 This is a fixed-size struct, so that creation of an iterator doesn't need | |
344 memory allocation on the heap. */ | |
345 typedef struct | |
346 { | |
347 /* For fast dispatch of gl_list_iterator_next. */ | |
348 const struct gl_list_implementation *vtable; | |
349 /* For detecting whether the last returned element was removed. */ | |
350 gl_list_t list; | |
351 size_t count; | |
352 /* Other, implementation-private fields. */ | |
353 void *p; void *q; | |
354 size_t i; size_t j; | |
355 } gl_list_iterator_t; | |
356 | |
357 /* Create an iterator traversing a list. | |
358 The list contents must not be modified while the iterator is in use, | |
359 except for replacing or removing the last returned element. */ | |
360 extern gl_list_iterator_t gl_list_iterator (gl_list_t list); | |
361 | |
362 /* Create an iterator traversing the element with indices i, | |
363 start_index <= i < end_index, of a list. | |
364 The list contents must not be modified while the iterator is in use, | |
365 except for replacing or removing the last returned element. */ | |
366 extern gl_list_iterator_t gl_list_iterator_from_to (gl_list_t list, | |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12081
diff
changeset
|
367 size_t start_index, |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12081
diff
changeset
|
368 size_t end_index); |
6984 | 369 |
370 /* If there is a next element, store the next element in *ELTP, store its | |
371 node in *NODEP if NODEP is non-NULL, advance the iterator and return true. | |
372 Otherwise, return false. */ | |
373 extern bool gl_list_iterator_next (gl_list_iterator_t *iterator, | |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12081
diff
changeset
|
374 const void **eltp, gl_list_node_t *nodep); |
6984 | 375 |
376 /* Free an iterator. */ | |
377 extern void gl_list_iterator_free (gl_list_iterator_t *iterator); | |
378 | |
379 /* ---------------------- Sorted gl_list_t Data Type ---------------------- */ | |
380 | |
381 /* The following functions are for lists without duplicates where the | |
382 order is given by a sort criterion. */ | |
383 | |
384 /* Type of function used to compare two elements. Same as for qsort(). | |
385 NULL denotes pointer comparison. */ | |
386 typedef int (*gl_listelement_compar_fn) (const void *elt1, const void *elt2); | |
387 | |
388 /* Search whether an element is already in the list. | |
389 The list is assumed to be sorted with COMPAR. | |
390 Return its node if found, or NULL if not present in the list. | |
391 If the list contains several copies of ELT, the node of the leftmost one is | |
392 returned. */ | |
393 extern gl_list_node_t gl_sortedlist_search (gl_list_t list, | |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12081
diff
changeset
|
394 gl_listelement_compar_fn compar, |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12081
diff
changeset
|
395 const void *elt); |
6984 | 396 |
397 /* Search whether an element is already in the list. | |
398 The list is assumed to be sorted with COMPAR. | |
7410
9704ff2cbdfe
Add bounded list search operations.
Bruno Haible <bruno@clisp.org>
parents:
7405
diff
changeset
|
399 Only list elements with indices >= START_INDEX and < END_INDEX are |
9704ff2cbdfe
Add bounded list search operations.
Bruno Haible <bruno@clisp.org>
parents:
7405
diff
changeset
|
400 considered; the implementation uses these bounds to minimize the number |
9704ff2cbdfe
Add bounded list search operations.
Bruno Haible <bruno@clisp.org>
parents:
7405
diff
changeset
|
401 of COMPAR invocations. |
9704ff2cbdfe
Add bounded list search operations.
Bruno Haible <bruno@clisp.org>
parents:
7405
diff
changeset
|
402 Return its node if found, or NULL if not present in the list. |
9704ff2cbdfe
Add bounded list search operations.
Bruno Haible <bruno@clisp.org>
parents:
7405
diff
changeset
|
403 If the list contains several copies of ELT, the node of the leftmost one is |
9704ff2cbdfe
Add bounded list search operations.
Bruno Haible <bruno@clisp.org>
parents:
7405
diff
changeset
|
404 returned. */ |
9704ff2cbdfe
Add bounded list search operations.
Bruno Haible <bruno@clisp.org>
parents:
7405
diff
changeset
|
405 extern gl_list_node_t gl_sortedlist_search_from_to (gl_list_t list, |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12081
diff
changeset
|
406 gl_listelement_compar_fn compar, |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12081
diff
changeset
|
407 size_t start_index, |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12081
diff
changeset
|
408 size_t end_index, |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12081
diff
changeset
|
409 const void *elt); |
7410
9704ff2cbdfe
Add bounded list search operations.
Bruno Haible <bruno@clisp.org>
parents:
7405
diff
changeset
|
410 |
9704ff2cbdfe
Add bounded list search operations.
Bruno Haible <bruno@clisp.org>
parents:
7405
diff
changeset
|
411 /* Search whether an element is already in the list. |
9704ff2cbdfe
Add bounded list search operations.
Bruno Haible <bruno@clisp.org>
parents:
7405
diff
changeset
|
412 The list is assumed to be sorted with COMPAR. |
6984 | 413 Return its position if found, or (size_t)(-1) if not present in the list. |
414 If the list contains several copies of ELT, the position of the leftmost one | |
415 is returned. */ | |
416 extern size_t gl_sortedlist_indexof (gl_list_t list, | |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12081
diff
changeset
|
417 gl_listelement_compar_fn compar, |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12081
diff
changeset
|
418 const void *elt); |
6984 | 419 |
7410
9704ff2cbdfe
Add bounded list search operations.
Bruno Haible <bruno@clisp.org>
parents:
7405
diff
changeset
|
420 /* Search whether an element is already in the list. |
9704ff2cbdfe
Add bounded list search operations.
Bruno Haible <bruno@clisp.org>
parents:
7405
diff
changeset
|
421 The list is assumed to be sorted with COMPAR. |
9704ff2cbdfe
Add bounded list search operations.
Bruno Haible <bruno@clisp.org>
parents:
7405
diff
changeset
|
422 Only list elements with indices >= START_INDEX and < END_INDEX are |
9704ff2cbdfe
Add bounded list search operations.
Bruno Haible <bruno@clisp.org>
parents:
7405
diff
changeset
|
423 considered; the implementation uses these bounds to minimize the number |
9704ff2cbdfe
Add bounded list search operations.
Bruno Haible <bruno@clisp.org>
parents:
7405
diff
changeset
|
424 of COMPAR invocations. |
9704ff2cbdfe
Add bounded list search operations.
Bruno Haible <bruno@clisp.org>
parents:
7405
diff
changeset
|
425 Return its position if found, or (size_t)(-1) if not present in the list. |
9704ff2cbdfe
Add bounded list search operations.
Bruno Haible <bruno@clisp.org>
parents:
7405
diff
changeset
|
426 If the list contains several copies of ELT, the position of the leftmost one |
9704ff2cbdfe
Add bounded list search operations.
Bruno Haible <bruno@clisp.org>
parents:
7405
diff
changeset
|
427 is returned. */ |
9704ff2cbdfe
Add bounded list search operations.
Bruno Haible <bruno@clisp.org>
parents:
7405
diff
changeset
|
428 extern size_t gl_sortedlist_indexof_from_to (gl_list_t list, |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12081
diff
changeset
|
429 gl_listelement_compar_fn compar, |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12081
diff
changeset
|
430 size_t start_index, |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12081
diff
changeset
|
431 size_t end_index, |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12081
diff
changeset
|
432 const void *elt); |
7410
9704ff2cbdfe
Add bounded list search operations.
Bruno Haible <bruno@clisp.org>
parents:
7405
diff
changeset
|
433 |
6984 | 434 /* Add an element at the appropriate position in the list. |
435 The list is assumed to be sorted with COMPAR. | |
436 Return its node. */ | |
12445
a8c91b846640
Move the malloc checking from module 'list' to new module 'xlist'.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
437 #if 0 /* declared in gl_xlist.h */ |
6984 | 438 extern gl_list_node_t gl_sortedlist_add (gl_list_t list, |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12081
diff
changeset
|
439 gl_listelement_compar_fn compar, |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12081
diff
changeset
|
440 const void *elt); |
12445
a8c91b846640
Move the malloc checking from module 'list' to new module 'xlist'.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
441 #endif |
a8c91b846640
Move the malloc checking from module 'list' to new module 'xlist'.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
442 /* Likewise. Return NULL upon out-of-memory. */ |
a8c91b846640
Move the malloc checking from module 'list' to new module 'xlist'.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
443 extern gl_list_node_t gl_sortedlist_nx_add (gl_list_t list, |
a8c91b846640
Move the malloc checking from module 'list' to new module 'xlist'.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
444 gl_listelement_compar_fn compar, |
a8c91b846640
Move the malloc checking from module 'list' to new module 'xlist'.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
445 const void *elt) |
a8c91b846640
Move the malloc checking from module 'list' to new module 'xlist'.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
446 #if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) |
a8c91b846640
Move the malloc checking from module 'list' to new module 'xlist'.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
447 __attribute__ ((__warn_unused_result__)) |
a8c91b846640
Move the malloc checking from module 'list' to new module 'xlist'.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
448 #endif |
a8c91b846640
Move the malloc checking from module 'list' to new module 'xlist'.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
449 ; |
6984 | 450 |
451 /* Search and remove an element from the list. | |
452 The list is assumed to be sorted with COMPAR. | |
453 Return true if it was found and removed. | |
454 If the list contains several copies of ELT, only the leftmost one is | |
455 removed. */ | |
456 extern bool gl_sortedlist_remove (gl_list_t list, | |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12081
diff
changeset
|
457 gl_listelement_compar_fn compar, |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12081
diff
changeset
|
458 const void *elt); |
6984 | 459 |
460 /* ------------------------ Implementation Details ------------------------ */ | |
461 | |
462 struct gl_list_implementation | |
463 { | |
7554 | 464 /* gl_list_t functions. */ |
12445
a8c91b846640
Move the malloc checking from module 'list' to new module 'xlist'.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
465 gl_list_t (*nx_create_empty) (gl_list_implementation_t implementation, |
a8c91b846640
Move the malloc checking from module 'list' to new module 'xlist'.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
466 gl_listelement_equals_fn equals_fn, |
a8c91b846640
Move the malloc checking from module 'list' to new module 'xlist'.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
467 gl_listelement_hashcode_fn hashcode_fn, |
a8c91b846640
Move the malloc checking from module 'list' to new module 'xlist'.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
468 gl_listelement_dispose_fn dispose_fn, |
a8c91b846640
Move the malloc checking from module 'list' to new module 'xlist'.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
469 bool allow_duplicates); |
a8c91b846640
Move the malloc checking from module 'list' to new module 'xlist'.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
470 gl_list_t (*nx_create) (gl_list_implementation_t implementation, |
a8c91b846640
Move the malloc checking from module 'list' to new module 'xlist'.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
471 gl_listelement_equals_fn equals_fn, |
a8c91b846640
Move the malloc checking from module 'list' to new module 'xlist'.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
472 gl_listelement_hashcode_fn hashcode_fn, |
a8c91b846640
Move the malloc checking from module 'list' to new module 'xlist'.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
473 gl_listelement_dispose_fn dispose_fn, |
a8c91b846640
Move the malloc checking from module 'list' to new module 'xlist'.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
474 bool allow_duplicates, |
a8c91b846640
Move the malloc checking from module 'list' to new module 'xlist'.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
475 size_t count, const void **contents); |
6984 | 476 size_t (*size) (gl_list_t list); |
477 const void * (*node_value) (gl_list_t list, gl_list_node_t node); | |
12445
a8c91b846640
Move the malloc checking from module 'list' to new module 'xlist'.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
478 int (*node_nx_set_value) (gl_list_t list, gl_list_node_t node, |
a8c91b846640
Move the malloc checking from module 'list' to new module 'xlist'.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
479 const void *elt); |
6984 | 480 gl_list_node_t (*next_node) (gl_list_t list, gl_list_node_t node); |
481 gl_list_node_t (*previous_node) (gl_list_t list, gl_list_node_t node); | |
482 const void * (*get_at) (gl_list_t list, size_t position); | |
12445
a8c91b846640
Move the malloc checking from module 'list' to new module 'xlist'.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
483 gl_list_node_t (*nx_set_at) (gl_list_t list, size_t position, |
a8c91b846640
Move the malloc checking from module 'list' to new module 'xlist'.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
484 const void *elt); |
7405
0de49c40e105
Add searching operations, limited to a subsequence of the list.
Bruno Haible <bruno@clisp.org>
parents:
6984
diff
changeset
|
485 gl_list_node_t (*search_from_to) (gl_list_t list, size_t start_index, |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12081
diff
changeset
|
486 size_t end_index, const void *elt); |
7405
0de49c40e105
Add searching operations, limited to a subsequence of the list.
Bruno Haible <bruno@clisp.org>
parents:
6984
diff
changeset
|
487 size_t (*indexof_from_to) (gl_list_t list, size_t start_index, |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12081
diff
changeset
|
488 size_t end_index, const void *elt); |
12445
a8c91b846640
Move the malloc checking from module 'list' to new module 'xlist'.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
489 gl_list_node_t (*nx_add_first) (gl_list_t list, const void *elt); |
a8c91b846640
Move the malloc checking from module 'list' to new module 'xlist'.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
490 gl_list_node_t (*nx_add_last) (gl_list_t list, const void *elt); |
a8c91b846640
Move the malloc checking from module 'list' to new module 'xlist'.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
491 gl_list_node_t (*nx_add_before) (gl_list_t list, gl_list_node_t node, |
a8c91b846640
Move the malloc checking from module 'list' to new module 'xlist'.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
492 const void *elt); |
a8c91b846640
Move the malloc checking from module 'list' to new module 'xlist'.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
493 gl_list_node_t (*nx_add_after) (gl_list_t list, gl_list_node_t node, |
a8c91b846640
Move the malloc checking from module 'list' to new module 'xlist'.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
494 const void *elt); |
a8c91b846640
Move the malloc checking from module 'list' to new module 'xlist'.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
495 gl_list_node_t (*nx_add_at) (gl_list_t list, size_t position, |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12081
diff
changeset
|
496 const void *elt); |
6984 | 497 bool (*remove_node) (gl_list_t list, gl_list_node_t node); |
498 bool (*remove_at) (gl_list_t list, size_t position); | |
12081
e0b4f68f21c2
Avoid identifier clash with POSIX function 'remove' defined as a macro.
Bruno Haible <bruno@clisp.org>
parents:
9686
diff
changeset
|
499 bool (*remove_elt) (gl_list_t list, const void *elt); |
6984 | 500 void (*list_free) (gl_list_t list); |
7554 | 501 /* gl_list_iterator_t functions. */ |
6984 | 502 gl_list_iterator_t (*iterator) (gl_list_t list); |
503 gl_list_iterator_t (*iterator_from_to) (gl_list_t list, | |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12081
diff
changeset
|
504 size_t start_index, |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12081
diff
changeset
|
505 size_t end_index); |
6984 | 506 bool (*iterator_next) (gl_list_iterator_t *iterator, |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12081
diff
changeset
|
507 const void **eltp, gl_list_node_t *nodep); |
6984 | 508 void (*iterator_free) (gl_list_iterator_t *iterator); |
7554 | 509 /* Sorted gl_list_t functions. */ |
6984 | 510 gl_list_node_t (*sortedlist_search) (gl_list_t list, |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12081
diff
changeset
|
511 gl_listelement_compar_fn compar, |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12081
diff
changeset
|
512 const void *elt); |
7410
9704ff2cbdfe
Add bounded list search operations.
Bruno Haible <bruno@clisp.org>
parents:
7405
diff
changeset
|
513 gl_list_node_t (*sortedlist_search_from_to) (gl_list_t list, |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12081
diff
changeset
|
514 gl_listelement_compar_fn compar, |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12081
diff
changeset
|
515 size_t start_index, |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12081
diff
changeset
|
516 size_t end_index, |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12081
diff
changeset
|
517 const void *elt); |
6984 | 518 size_t (*sortedlist_indexof) (gl_list_t list, |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12081
diff
changeset
|
519 gl_listelement_compar_fn compar, |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12081
diff
changeset
|
520 const void *elt); |
7410
9704ff2cbdfe
Add bounded list search operations.
Bruno Haible <bruno@clisp.org>
parents:
7405
diff
changeset
|
521 size_t (*sortedlist_indexof_from_to) (gl_list_t list, |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12081
diff
changeset
|
522 gl_listelement_compar_fn compar, |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12081
diff
changeset
|
523 size_t start_index, size_t end_index, |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12081
diff
changeset
|
524 const void *elt); |
12445
a8c91b846640
Move the malloc checking from module 'list' to new module 'xlist'.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
525 gl_list_node_t (*sortedlist_nx_add) (gl_list_t list, |
a8c91b846640
Move the malloc checking from module 'list' to new module 'xlist'.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
526 gl_listelement_compar_fn compar, |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12081
diff
changeset
|
527 const void *elt); |
6984 | 528 bool (*sortedlist_remove) (gl_list_t list, |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12081
diff
changeset
|
529 gl_listelement_compar_fn compar, |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12081
diff
changeset
|
530 const void *elt); |
6984 | 531 }; |
532 | |
533 struct gl_list_impl_base | |
534 { | |
535 const struct gl_list_implementation *vtable; | |
536 gl_listelement_equals_fn equals_fn; | |
537 gl_listelement_hashcode_fn hashcode_fn; | |
8438
238942284e2f
Allow the use of a destructor for the values stored in the list.
Bruno Haible <bruno@clisp.org>
parents:
7554
diff
changeset
|
538 gl_listelement_dispose_fn dispose_fn; |
6984 | 539 bool allow_duplicates; |
540 }; | |
541 | |
542 #if HAVE_INLINE | |
543 | |
544 /* Define all functions of this file as inline accesses to the | |
545 struct gl_list_implementation. | |
546 Use #define to avoid a warning because of extern vs. static. */ | |
547 | |
12445
a8c91b846640
Move the malloc checking from module 'list' to new module 'xlist'.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
548 # define gl_list_nx_create_empty gl_list_nx_create_empty_inline |
6984 | 549 static inline gl_list_t |
12445
a8c91b846640
Move the malloc checking from module 'list' to new module 'xlist'.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
550 gl_list_nx_create_empty (gl_list_implementation_t implementation, |
a8c91b846640
Move the malloc checking from module 'list' to new module 'xlist'.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
551 gl_listelement_equals_fn equals_fn, |
a8c91b846640
Move the malloc checking from module 'list' to new module 'xlist'.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
552 gl_listelement_hashcode_fn hashcode_fn, |
a8c91b846640
Move the malloc checking from module 'list' to new module 'xlist'.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
553 gl_listelement_dispose_fn dispose_fn, |
a8c91b846640
Move the malloc checking from module 'list' to new module 'xlist'.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
554 bool allow_duplicates) |
6984 | 555 { |
12445
a8c91b846640
Move the malloc checking from module 'list' to new module 'xlist'.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
556 return implementation->nx_create_empty (implementation, equals_fn, |
a8c91b846640
Move the malloc checking from module 'list' to new module 'xlist'.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
557 hashcode_fn, dispose_fn, |
a8c91b846640
Move the malloc checking from module 'list' to new module 'xlist'.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
558 allow_duplicates); |
6984 | 559 } |
560 | |
12445
a8c91b846640
Move the malloc checking from module 'list' to new module 'xlist'.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
561 # define gl_list_nx_create gl_list_nx_create_inline |
6984 | 562 static inline gl_list_t |
12445
a8c91b846640
Move the malloc checking from module 'list' to new module 'xlist'.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
563 gl_list_nx_create (gl_list_implementation_t implementation, |
a8c91b846640
Move the malloc checking from module 'list' to new module 'xlist'.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
564 gl_listelement_equals_fn equals_fn, |
a8c91b846640
Move the malloc checking from module 'list' to new module 'xlist'.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
565 gl_listelement_hashcode_fn hashcode_fn, |
a8c91b846640
Move the malloc checking from module 'list' to new module 'xlist'.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
566 gl_listelement_dispose_fn dispose_fn, |
a8c91b846640
Move the malloc checking from module 'list' to new module 'xlist'.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
567 bool allow_duplicates, |
a8c91b846640
Move the malloc checking from module 'list' to new module 'xlist'.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
568 size_t count, const void **contents) |
6984 | 569 { |
12445
a8c91b846640
Move the malloc checking from module 'list' to new module 'xlist'.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
570 return implementation->nx_create (implementation, equals_fn, hashcode_fn, |
a8c91b846640
Move the malloc checking from module 'list' to new module 'xlist'.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
571 dispose_fn, allow_duplicates, count, |
a8c91b846640
Move the malloc checking from module 'list' to new module 'xlist'.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
572 contents); |
6984 | 573 } |
574 | |
575 # define gl_list_size gl_list_size_inline | |
576 static inline size_t | |
577 gl_list_size (gl_list_t list) | |
578 { | |
579 return ((const struct gl_list_impl_base *) list)->vtable | |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12081
diff
changeset
|
580 ->size (list); |
6984 | 581 } |
582 | |
583 # define gl_list_node_value gl_list_node_value_inline | |
584 static inline const void * | |
585 gl_list_node_value (gl_list_t list, gl_list_node_t node) | |
586 { | |
587 return ((const struct gl_list_impl_base *) list)->vtable | |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12081
diff
changeset
|
588 ->node_value (list, node); |
6984 | 589 } |
590 | |
12445
a8c91b846640
Move the malloc checking from module 'list' to new module 'xlist'.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
591 # define gl_list_node_nx_set_value gl_list_node_nx_set_value_inline |
a8c91b846640
Move the malloc checking from module 'list' to new module 'xlist'.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
592 static inline int |
a8c91b846640
Move the malloc checking from module 'list' to new module 'xlist'.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
593 gl_list_node_nx_set_value (gl_list_t list, gl_list_node_t node, |
a8c91b846640
Move the malloc checking from module 'list' to new module 'xlist'.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
594 const void *elt) |
9686
25f7280c9cf0
New abstract list operation 'node_set_value'.
Bruno Haible <bruno@clisp.org>
parents:
9309
diff
changeset
|
595 { |
12445
a8c91b846640
Move the malloc checking from module 'list' to new module 'xlist'.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
596 return ((const struct gl_list_impl_base *) list)->vtable |
a8c91b846640
Move the malloc checking from module 'list' to new module 'xlist'.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
597 ->node_nx_set_value (list, node, elt); |
9686
25f7280c9cf0
New abstract list operation 'node_set_value'.
Bruno Haible <bruno@clisp.org>
parents:
9309
diff
changeset
|
598 } |
25f7280c9cf0
New abstract list operation 'node_set_value'.
Bruno Haible <bruno@clisp.org>
parents:
9309
diff
changeset
|
599 |
6984 | 600 # define gl_list_next_node gl_list_next_node_inline |
601 static inline gl_list_node_t | |
602 gl_list_next_node (gl_list_t list, gl_list_node_t node) | |
603 { | |
604 return ((const struct gl_list_impl_base *) list)->vtable | |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12081
diff
changeset
|
605 ->next_node (list, node); |
6984 | 606 } |
607 | |
608 # define gl_list_previous_node gl_list_previous_node_inline | |
609 static inline gl_list_node_t | |
610 gl_list_previous_node (gl_list_t list, gl_list_node_t node) | |
611 { | |
612 return ((const struct gl_list_impl_base *) list)->vtable | |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12081
diff
changeset
|
613 ->previous_node (list, node); |
6984 | 614 } |
615 | |
616 # define gl_list_get_at gl_list_get_at_inline | |
617 static inline const void * | |
618 gl_list_get_at (gl_list_t list, size_t position) | |
619 { | |
620 return ((const struct gl_list_impl_base *) list)->vtable | |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12081
diff
changeset
|
621 ->get_at (list, position); |
6984 | 622 } |
623 | |
12445
a8c91b846640
Move the malloc checking from module 'list' to new module 'xlist'.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
624 # define gl_list_nx_set_at gl_list_nx_set_at_inline |
6984 | 625 static inline gl_list_node_t |
12445
a8c91b846640
Move the malloc checking from module 'list' to new module 'xlist'.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
626 gl_list_nx_set_at (gl_list_t list, size_t position, const void *elt) |
6984 | 627 { |
628 return ((const struct gl_list_impl_base *) list)->vtable | |
12445
a8c91b846640
Move the malloc checking from module 'list' to new module 'xlist'.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
629 ->nx_set_at (list, position, elt); |
6984 | 630 } |
631 | |
632 # define gl_list_search gl_list_search_inline | |
633 static inline gl_list_node_t | |
634 gl_list_search (gl_list_t list, const void *elt) | |
635 { | |
7405
0de49c40e105
Add searching operations, limited to a subsequence of the list.
Bruno Haible <bruno@clisp.org>
parents:
6984
diff
changeset
|
636 size_t size = ((const struct gl_list_impl_base *) list)->vtable->size (list); |
6984 | 637 return ((const struct gl_list_impl_base *) list)->vtable |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12081
diff
changeset
|
638 ->search_from_to (list, 0, size, elt); |
7405
0de49c40e105
Add searching operations, limited to a subsequence of the list.
Bruno Haible <bruno@clisp.org>
parents:
6984
diff
changeset
|
639 } |
0de49c40e105
Add searching operations, limited to a subsequence of the list.
Bruno Haible <bruno@clisp.org>
parents:
6984
diff
changeset
|
640 |
0de49c40e105
Add searching operations, limited to a subsequence of the list.
Bruno Haible <bruno@clisp.org>
parents:
6984
diff
changeset
|
641 # define gl_list_search_from gl_list_search_from_inline |
0de49c40e105
Add searching operations, limited to a subsequence of the list.
Bruno Haible <bruno@clisp.org>
parents:
6984
diff
changeset
|
642 static inline gl_list_node_t |
0de49c40e105
Add searching operations, limited to a subsequence of the list.
Bruno Haible <bruno@clisp.org>
parents:
6984
diff
changeset
|
643 gl_list_search_from (gl_list_t list, size_t start_index, const void *elt) |
0de49c40e105
Add searching operations, limited to a subsequence of the list.
Bruno Haible <bruno@clisp.org>
parents:
6984
diff
changeset
|
644 { |
0de49c40e105
Add searching operations, limited to a subsequence of the list.
Bruno Haible <bruno@clisp.org>
parents:
6984
diff
changeset
|
645 size_t size = ((const struct gl_list_impl_base *) list)->vtable->size (list); |
0de49c40e105
Add searching operations, limited to a subsequence of the list.
Bruno Haible <bruno@clisp.org>
parents:
6984
diff
changeset
|
646 return ((const struct gl_list_impl_base *) list)->vtable |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12081
diff
changeset
|
647 ->search_from_to (list, start_index, size, elt); |
7405
0de49c40e105
Add searching operations, limited to a subsequence of the list.
Bruno Haible <bruno@clisp.org>
parents:
6984
diff
changeset
|
648 } |
0de49c40e105
Add searching operations, limited to a subsequence of the list.
Bruno Haible <bruno@clisp.org>
parents:
6984
diff
changeset
|
649 |
0de49c40e105
Add searching operations, limited to a subsequence of the list.
Bruno Haible <bruno@clisp.org>
parents:
6984
diff
changeset
|
650 # define gl_list_search_from_to gl_list_search_from_to_inline |
0de49c40e105
Add searching operations, limited to a subsequence of the list.
Bruno Haible <bruno@clisp.org>
parents:
6984
diff
changeset
|
651 static inline gl_list_node_t |
0de49c40e105
Add searching operations, limited to a subsequence of the list.
Bruno Haible <bruno@clisp.org>
parents:
6984
diff
changeset
|
652 gl_list_search_from_to (gl_list_t list, size_t start_index, size_t end_index, |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12081
diff
changeset
|
653 const void *elt) |
7405
0de49c40e105
Add searching operations, limited to a subsequence of the list.
Bruno Haible <bruno@clisp.org>
parents:
6984
diff
changeset
|
654 { |
0de49c40e105
Add searching operations, limited to a subsequence of the list.
Bruno Haible <bruno@clisp.org>
parents:
6984
diff
changeset
|
655 return ((const struct gl_list_impl_base *) list)->vtable |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12081
diff
changeset
|
656 ->search_from_to (list, start_index, end_index, elt); |
6984 | 657 } |
658 | |
659 # define gl_list_indexof gl_list_indexof_inline | |
660 static inline size_t | |
661 gl_list_indexof (gl_list_t list, const void *elt) | |
662 { | |
7405
0de49c40e105
Add searching operations, limited to a subsequence of the list.
Bruno Haible <bruno@clisp.org>
parents:
6984
diff
changeset
|
663 size_t size = ((const struct gl_list_impl_base *) list)->vtable->size (list); |
6984 | 664 return ((const struct gl_list_impl_base *) list)->vtable |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12081
diff
changeset
|
665 ->indexof_from_to (list, 0, size, elt); |
7405
0de49c40e105
Add searching operations, limited to a subsequence of the list.
Bruno Haible <bruno@clisp.org>
parents:
6984
diff
changeset
|
666 } |
0de49c40e105
Add searching operations, limited to a subsequence of the list.
Bruno Haible <bruno@clisp.org>
parents:
6984
diff
changeset
|
667 |
0de49c40e105
Add searching operations, limited to a subsequence of the list.
Bruno Haible <bruno@clisp.org>
parents:
6984
diff
changeset
|
668 # define gl_list_indexof_from gl_list_indexof_from_inline |
0de49c40e105
Add searching operations, limited to a subsequence of the list.
Bruno Haible <bruno@clisp.org>
parents:
6984
diff
changeset
|
669 static inline size_t |
0de49c40e105
Add searching operations, limited to a subsequence of the list.
Bruno Haible <bruno@clisp.org>
parents:
6984
diff
changeset
|
670 gl_list_indexof_from (gl_list_t list, size_t start_index, const void *elt) |
0de49c40e105
Add searching operations, limited to a subsequence of the list.
Bruno Haible <bruno@clisp.org>
parents:
6984
diff
changeset
|
671 { |
0de49c40e105
Add searching operations, limited to a subsequence of the list.
Bruno Haible <bruno@clisp.org>
parents:
6984
diff
changeset
|
672 size_t size = ((const struct gl_list_impl_base *) list)->vtable->size (list); |
0de49c40e105
Add searching operations, limited to a subsequence of the list.
Bruno Haible <bruno@clisp.org>
parents:
6984
diff
changeset
|
673 return ((const struct gl_list_impl_base *) list)->vtable |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12081
diff
changeset
|
674 ->indexof_from_to (list, start_index, size, elt); |
7405
0de49c40e105
Add searching operations, limited to a subsequence of the list.
Bruno Haible <bruno@clisp.org>
parents:
6984
diff
changeset
|
675 } |
0de49c40e105
Add searching operations, limited to a subsequence of the list.
Bruno Haible <bruno@clisp.org>
parents:
6984
diff
changeset
|
676 |
0de49c40e105
Add searching operations, limited to a subsequence of the list.
Bruno Haible <bruno@clisp.org>
parents:
6984
diff
changeset
|
677 # define gl_list_indexof_from_to gl_list_indexof_from_to_inline |
0de49c40e105
Add searching operations, limited to a subsequence of the list.
Bruno Haible <bruno@clisp.org>
parents:
6984
diff
changeset
|
678 static inline size_t |
0de49c40e105
Add searching operations, limited to a subsequence of the list.
Bruno Haible <bruno@clisp.org>
parents:
6984
diff
changeset
|
679 gl_list_indexof_from_to (gl_list_t list, size_t start_index, size_t end_index, |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12081
diff
changeset
|
680 const void *elt) |
7405
0de49c40e105
Add searching operations, limited to a subsequence of the list.
Bruno Haible <bruno@clisp.org>
parents:
6984
diff
changeset
|
681 { |
0de49c40e105
Add searching operations, limited to a subsequence of the list.
Bruno Haible <bruno@clisp.org>
parents:
6984
diff
changeset
|
682 return ((const struct gl_list_impl_base *) list)->vtable |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12081
diff
changeset
|
683 ->indexof_from_to (list, start_index, end_index, elt); |
6984 | 684 } |
685 | |
12445
a8c91b846640
Move the malloc checking from module 'list' to new module 'xlist'.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
686 # define gl_list_nx_add_first gl_list_nx_add_first_inline |
6984 | 687 static inline gl_list_node_t |
12445
a8c91b846640
Move the malloc checking from module 'list' to new module 'xlist'.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
688 gl_list_nx_add_first (gl_list_t list, const void *elt) |
6984 | 689 { |
690 return ((const struct gl_list_impl_base *) list)->vtable | |
12445
a8c91b846640
Move the malloc checking from module 'list' to new module 'xlist'.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
691 ->nx_add_first (list, elt); |
6984 | 692 } |
693 | |
12445
a8c91b846640
Move the malloc checking from module 'list' to new module 'xlist'.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
694 # define gl_list_nx_add_last gl_list_nx_add_last_inline |
6984 | 695 static inline gl_list_node_t |
12445
a8c91b846640
Move the malloc checking from module 'list' to new module 'xlist'.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
696 gl_list_nx_add_last (gl_list_t list, const void *elt) |
6984 | 697 { |
698 return ((const struct gl_list_impl_base *) list)->vtable | |
12445
a8c91b846640
Move the malloc checking from module 'list' to new module 'xlist'.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
699 ->nx_add_last (list, elt); |
6984 | 700 } |
701 | |
12445
a8c91b846640
Move the malloc checking from module 'list' to new module 'xlist'.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
702 # define gl_list_nx_add_before gl_list_nx_add_before_inline |
6984 | 703 static inline gl_list_node_t |
12445
a8c91b846640
Move the malloc checking from module 'list' to new module 'xlist'.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
704 gl_list_nx_add_before (gl_list_t list, gl_list_node_t node, const void *elt) |
6984 | 705 { |
706 return ((const struct gl_list_impl_base *) list)->vtable | |
12445
a8c91b846640
Move the malloc checking from module 'list' to new module 'xlist'.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
707 ->nx_add_before (list, node, elt); |
6984 | 708 } |
709 | |
12445
a8c91b846640
Move the malloc checking from module 'list' to new module 'xlist'.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
710 # define gl_list_nx_add_after gl_list_nx_add_after_inline |
6984 | 711 static inline gl_list_node_t |
12445
a8c91b846640
Move the malloc checking from module 'list' to new module 'xlist'.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
712 gl_list_nx_add_after (gl_list_t list, gl_list_node_t node, const void *elt) |
6984 | 713 { |
714 return ((const struct gl_list_impl_base *) list)->vtable | |
12445
a8c91b846640
Move the malloc checking from module 'list' to new module 'xlist'.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
715 ->nx_add_after (list, node, elt); |
6984 | 716 } |
717 | |
12445
a8c91b846640
Move the malloc checking from module 'list' to new module 'xlist'.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
718 # define gl_list_nx_add_at gl_list_nx_add_at_inline |
6984 | 719 static inline gl_list_node_t |
12445
a8c91b846640
Move the malloc checking from module 'list' to new module 'xlist'.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
720 gl_list_nx_add_at (gl_list_t list, size_t position, const void *elt) |
6984 | 721 { |
722 return ((const struct gl_list_impl_base *) list)->vtable | |
12445
a8c91b846640
Move the malloc checking from module 'list' to new module 'xlist'.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
723 ->nx_add_at (list, position, elt); |
6984 | 724 } |
725 | |
726 # define gl_list_remove_node gl_list_remove_node_inline | |
727 static inline bool | |
728 gl_list_remove_node (gl_list_t list, gl_list_node_t node) | |
729 { | |
730 return ((const struct gl_list_impl_base *) list)->vtable | |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12081
diff
changeset
|
731 ->remove_node (list, node); |
6984 | 732 } |
733 | |
734 # define gl_list_remove_at gl_list_remove_at_inline | |
735 static inline bool | |
736 gl_list_remove_at (gl_list_t list, size_t position) | |
737 { | |
738 return ((const struct gl_list_impl_base *) list)->vtable | |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12081
diff
changeset
|
739 ->remove_at (list, position); |
6984 | 740 } |
741 | |
742 # define gl_list_remove gl_list_remove_inline | |
743 static inline bool | |
744 gl_list_remove (gl_list_t list, const void *elt) | |
745 { | |
746 return ((const struct gl_list_impl_base *) list)->vtable | |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12081
diff
changeset
|
747 ->remove_elt (list, elt); |
6984 | 748 } |
749 | |
750 # define gl_list_free gl_list_free_inline | |
751 static inline void | |
752 gl_list_free (gl_list_t list) | |
753 { | |
754 ((const struct gl_list_impl_base *) list)->vtable->list_free (list); | |
755 } | |
756 | |
757 # define gl_list_iterator gl_list_iterator_inline | |
758 static inline gl_list_iterator_t | |
759 gl_list_iterator (gl_list_t list) | |
760 { | |
761 return ((const struct gl_list_impl_base *) list)->vtable | |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12081
diff
changeset
|
762 ->iterator (list); |
6984 | 763 } |
764 | |
765 # define gl_list_iterator_from_to gl_list_iterator_from_to_inline | |
766 static inline gl_list_iterator_t | |
767 gl_list_iterator_from_to (gl_list_t list, size_t start_index, size_t end_index) | |
768 { | |
769 return ((const struct gl_list_impl_base *) list)->vtable | |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12081
diff
changeset
|
770 ->iterator_from_to (list, start_index, end_index); |
6984 | 771 } |
772 | |
773 # define gl_list_iterator_next gl_list_iterator_next_inline | |
774 static inline bool | |
775 gl_list_iterator_next (gl_list_iterator_t *iterator, | |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12081
diff
changeset
|
776 const void **eltp, gl_list_node_t *nodep) |
6984 | 777 { |
778 return iterator->vtable->iterator_next (iterator, eltp, nodep); | |
779 } | |
780 | |
781 # define gl_list_iterator_free gl_list_iterator_free_inline | |
782 static inline void | |
783 gl_list_iterator_free (gl_list_iterator_t *iterator) | |
784 { | |
785 iterator->vtable->iterator_free (iterator); | |
786 } | |
787 | |
788 # define gl_sortedlist_search gl_sortedlist_search_inline | |
789 static inline gl_list_node_t | |
790 gl_sortedlist_search (gl_list_t list, gl_listelement_compar_fn compar, const void *elt) | |
791 { | |
792 return ((const struct gl_list_impl_base *) list)->vtable | |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12081
diff
changeset
|
793 ->sortedlist_search (list, compar, elt); |
6984 | 794 } |
795 | |
7410
9704ff2cbdfe
Add bounded list search operations.
Bruno Haible <bruno@clisp.org>
parents:
7405
diff
changeset
|
796 # define gl_sortedlist_search_from_to gl_sortedlist_search_from_to_inline |
9704ff2cbdfe
Add bounded list search operations.
Bruno Haible <bruno@clisp.org>
parents:
7405
diff
changeset
|
797 static inline gl_list_node_t |
9704ff2cbdfe
Add bounded list search operations.
Bruno Haible <bruno@clisp.org>
parents:
7405
diff
changeset
|
798 gl_sortedlist_search_from_to (gl_list_t list, gl_listelement_compar_fn compar, size_t start_index, size_t end_index, const void *elt) |
9704ff2cbdfe
Add bounded list search operations.
Bruno Haible <bruno@clisp.org>
parents:
7405
diff
changeset
|
799 { |
9704ff2cbdfe
Add bounded list search operations.
Bruno Haible <bruno@clisp.org>
parents:
7405
diff
changeset
|
800 return ((const struct gl_list_impl_base *) list)->vtable |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12081
diff
changeset
|
801 ->sortedlist_search_from_to (list, compar, start_index, end_index, |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12081
diff
changeset
|
802 elt); |
7410
9704ff2cbdfe
Add bounded list search operations.
Bruno Haible <bruno@clisp.org>
parents:
7405
diff
changeset
|
803 } |
9704ff2cbdfe
Add bounded list search operations.
Bruno Haible <bruno@clisp.org>
parents:
7405
diff
changeset
|
804 |
6984 | 805 # define gl_sortedlist_indexof gl_sortedlist_indexof_inline |
806 static inline size_t | |
807 gl_sortedlist_indexof (gl_list_t list, gl_listelement_compar_fn compar, const void *elt) | |
808 { | |
809 return ((const struct gl_list_impl_base *) list)->vtable | |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12081
diff
changeset
|
810 ->sortedlist_indexof (list, compar, elt); |
6984 | 811 } |
812 | |
7410
9704ff2cbdfe
Add bounded list search operations.
Bruno Haible <bruno@clisp.org>
parents:
7405
diff
changeset
|
813 # define gl_sortedlist_indexof_from_to gl_sortedlist_indexof_from_to_inline |
9704ff2cbdfe
Add bounded list search operations.
Bruno Haible <bruno@clisp.org>
parents:
7405
diff
changeset
|
814 static inline size_t |
9704ff2cbdfe
Add bounded list search operations.
Bruno Haible <bruno@clisp.org>
parents:
7405
diff
changeset
|
815 gl_sortedlist_indexof_from_to (gl_list_t list, gl_listelement_compar_fn compar, size_t start_index, size_t end_index, const void *elt) |
9704ff2cbdfe
Add bounded list search operations.
Bruno Haible <bruno@clisp.org>
parents:
7405
diff
changeset
|
816 { |
9704ff2cbdfe
Add bounded list search operations.
Bruno Haible <bruno@clisp.org>
parents:
7405
diff
changeset
|
817 return ((const struct gl_list_impl_base *) list)->vtable |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12081
diff
changeset
|
818 ->sortedlist_indexof_from_to (list, compar, start_index, end_index, |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12081
diff
changeset
|
819 elt); |
7410
9704ff2cbdfe
Add bounded list search operations.
Bruno Haible <bruno@clisp.org>
parents:
7405
diff
changeset
|
820 } |
9704ff2cbdfe
Add bounded list search operations.
Bruno Haible <bruno@clisp.org>
parents:
7405
diff
changeset
|
821 |
12445
a8c91b846640
Move the malloc checking from module 'list' to new module 'xlist'.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
822 # define gl_sortedlist_nx_add gl_sortedlist_nx_add_inline |
6984 | 823 static inline gl_list_node_t |
12445
a8c91b846640
Move the malloc checking from module 'list' to new module 'xlist'.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
824 gl_sortedlist_nx_add (gl_list_t list, gl_listelement_compar_fn compar, const void *elt) |
6984 | 825 { |
826 return ((const struct gl_list_impl_base *) list)->vtable | |
12445
a8c91b846640
Move the malloc checking from module 'list' to new module 'xlist'.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
827 ->sortedlist_nx_add (list, compar, elt); |
6984 | 828 } |
829 | |
830 # define gl_sortedlist_remove gl_sortedlist_remove_inline | |
831 static inline bool | |
832 gl_sortedlist_remove (gl_list_t list, gl_listelement_compar_fn compar, const void *elt) | |
833 { | |
834 return ((const struct gl_list_impl_base *) list)->vtable | |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12081
diff
changeset
|
835 ->sortedlist_remove (list, compar, elt); |
6984 | 836 } |
837 | |
838 #endif | |
839 | |
840 #ifdef __cplusplus | |
841 } | |
842 #endif | |
843 | |
844 #endif /* _GL_LIST_H */ |