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
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
6984
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
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
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
3 Written by Bruno Haible <bruno@clisp.org>, 2006.
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
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
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
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
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
9
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
10 This program is distributed in the hope that it will be useful,
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
13 GNU General Public License for more details.
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
14
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
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
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
17
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
18 #ifndef _GL_LIST_H
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
19 #define _GL_LIST_H
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
20
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
21 #include <stdbool.h>
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
22 #include <stddef.h>
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
23
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
24 #ifdef __cplusplus
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
25 extern "C" {
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
26 #endif
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
27
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
28
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
29 /* gl_list is an abstract list data type. It can contain any number of
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
30 objects ('void *' or 'const void *' pointers) in any given order.
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
31 Duplicates are allowed, but can optionally be forbidden.
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
32
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
33 There are several implementations of this list datatype, optimized for
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
34 different operations or for memory. You can start using the simplest list
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
35 implementation, GL_ARRAY_LIST, and switch to a different implementation
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
36 later, when you realize which operations are performed the most frequently.
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
37 The API of the different implementations is exactly the same; when
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
38 switching to a different implementation, you only have to change the
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
39 gl_list_create call.
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
40
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
41 The implementations are:
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
42 GL_ARRAY_LIST a growable array
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
43 GL_CARRAY_LIST a growable circular array
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
44 GL_LINKED_LIST a linked list
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
45 GL_AVLTREE_LIST a binary tree (AVL tree)
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
46 GL_RBTREE_LIST a binary tree (red-black tree)
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
47 GL_LINKEDHASH_LIST a hash table with a linked list
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
48 GL_AVLTREEHASH_LIST a hash table with a binary tree (AVL tree)
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
49 GL_RBTREEHASH_LIST a hash table with a binary tree (red-black tree)
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
50
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
51 The memory consumption is asymptotically the same: O(1) for every object
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
52 in the list. When looking more closely at the average memory consumed
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
53 for an object, GL_ARRAY_LIST is the most compact representation, and
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
54 GL_LINKEDHASH_LIST and GL_TREEHASH_LIST need more memory.
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
55
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
56 The guaranteed average performance of the operations is, for a list of
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
57 n elements:
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
58
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
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
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
62
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
63 gl_list_size O(1) O(1) O(1) O(1) O(1)
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
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
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
66 gl_list_next_node O(1) O(1) O(log n) O(1) O(log n)
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
67 gl_list_previous_node O(1) O(1) O(log n) O(1) O(log n)
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
68 gl_list_get_at O(1) O(n) O(log n) O(n) O(log n)
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
69 gl_list_set_at O(1) O(n) O(log n) O(n) O((log n)²)/O(log n)
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
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
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
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
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
76 gl_list_add_first O(n)/O(1) O(1) O(log n) O(1) O((log n)²)/O(log n)
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
77 gl_list_add_last O(1) O(1) O(log n) O(1) O((log n)²)/O(log n)
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
78 gl_list_add_before O(n) O(1) O(log n) O(1) O((log n)²)/O(log n)
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
79 gl_list_add_after O(n) O(1) O(log n) O(1) O((log n)²)/O(log n)
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
80 gl_list_add_at O(n) O(n) O(log n) O(n) O((log n)²)/O(log n)
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
81 gl_list_remove_node O(n) O(1) O(log n) O(n)/O(1) O((log n)²)/O(log n)
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
82 gl_list_remove_at O(n) O(n) O(log n) O(n) O((log n)²)/O(log n)
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
83 gl_list_remove O(n) O(n) O(n) O(n)/O(1) O((log n)²)/O(log n)
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
84 gl_list_iterator O(1) O(1) O(log n) O(1) O(log n)
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
85 gl_list_iterator_from_to O(1) O(n) O(log n) O(n) O(log n)
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
86 gl_list_iterator_next O(1) O(1) O(log n) O(1) O(log n)
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
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
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
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
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
91 gl_sortedlist_add O(n) O(n) O(log n) O(n) O((log n)²)/O(log n)
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
92 gl_sortedlist_remove O(n) O(n) O(log n) O(n) O((log n)²)/O(log n)
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
93 */
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
94
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
95 /* -------------------------- gl_list_t Data Type -------------------------- */
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
96
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
97 /* Type of function used to compare two elements.
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
98 NULL denotes pointer comparison. */
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
99 typedef bool (*gl_listelement_equals_fn) (const void *elt1, const void *elt2);
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
100
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
101 /* Type of function used to compute a hash code.
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
102 NULL denotes a function that depends only on the pointer itself. */
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
103 typedef size_t (*gl_listelement_hashcode_fn) (const void *elt);
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
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
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
109 struct gl_list_impl;
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
110 /* Type representing an entire list. */
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
111 typedef struct gl_list_impl * gl_list_t;
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
112
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
113 struct gl_list_node_impl;
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
114 /* Type representing the position of an element in the list, in a way that
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
115 is more adapted to the list implementation than a plain index.
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
116 Note: It is invalidated by insertions and removals! */
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
117 typedef struct gl_list_node_impl * gl_list_node_t;
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
118
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
119 struct gl_list_implementation;
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
120 /* Type representing a list datatype implementation. */
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
121 typedef const struct gl_list_implementation * gl_list_implementation_t;
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
122
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
123 /* Create an empty list.
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
124 IMPLEMENTATION is one of GL_ARRAY_LIST, GL_CARRAY_LIST, GL_LINKED_LIST,
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
125 GL_AVLTREE_LIST, GL_RBTREE_LIST, GL_LINKEDHASH_LIST, GL_AVLTREEHASH_LIST,
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
126 GL_RBTREEHASH_LIST.
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
127 EQUALS_FN is an element comparison function or NULL.
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
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
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
130 ALLOW_DUPLICATES is false if duplicate elements shall not be allowed in
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
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
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
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
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
145
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
146 /* Create a list with given contents.
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
147 IMPLEMENTATION is one of GL_ARRAY_LIST, GL_CARRAY_LIST, GL_LINKED_LIST,
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
148 GL_AVLTREE_LIST, GL_RBTREE_LIST, GL_LINKEDHASH_LIST, GL_AVLTREEHASH_LIST,
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
149 GL_RBTREEHASH_LIST.
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
150 EQUALS_FN is an element comparison function or NULL.
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
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
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
153 ALLOW_DUPLICATES is false if duplicate elements shall not be allowed in
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
154 the list. The implementation may verify this at runtime.
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
155 COUNT is the number of initial elements.
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
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
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
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
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
172
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
173 /* Return the current number of elements in a list. */
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
174 extern size_t gl_list_size (gl_list_t list);
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
175
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
176 /* Return the element value represented by a list node. */
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
177 extern const void * gl_list_node_value (gl_list_t list, gl_list_node_t node);
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
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
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
192 /* Return the node immediately after the given node in the list, or NULL
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
193 if the given node is the last (rightmost) one in the list. */
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
194 extern gl_list_node_t gl_list_next_node (gl_list_t list, gl_list_node_t node);
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
195
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
196 /* Return the node immediately before the given node in the list, or NULL
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
197 if the given node is the first (leftmost) one in the list. */
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
198 extern gl_list_node_t gl_list_previous_node (gl_list_t list, gl_list_node_t node);
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
199
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
200 /* Return the element at a given position in the list.
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
201 POSITION must be >= 0 and < gl_list_size (list). */
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
202 extern const void * gl_list_get_at (gl_list_t list, size_t position);
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
203
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
204 /* Replace the element at a given position in the list.
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
205 POSITION must be >= 0 and < gl_list_size (list).
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
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
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
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
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
218
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
219 /* Search whether an element is already in the list.
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
220 Return its node if found, or NULL if not present in the list. */
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
221 extern gl_list_node_t gl_list_search (gl_list_t list, const void *elt);
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
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
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
237 /* Search whether an element is already in the list.
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
238 Return its position if found, or (size_t)(-1) if not present in the list. */
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
239 extern size_t gl_list_indexof (gl_list_t list, const void *elt);
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
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
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
254 /* Add an element as the first element of the list.
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
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
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
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
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
265
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
266 /* Add an element as the last element of the list.
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
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
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
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
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
277
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
278 /* Add an element before a given element node of the list.
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
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
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
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
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
292
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
293 /* Add an element after a given element node of the list.
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
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
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
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
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
306
12458
fd1286c1d1b9 Fix typo in comment.
José E. Marchesi <jemarch@gnu.org>
parents: 12445
diff changeset
307 /* Add an element at a given position in the list.
6984
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
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
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
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
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
320
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
321 /* Remove an element from the list.
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
322 Return true. */
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
323 extern bool gl_list_remove_node (gl_list_t list, gl_list_node_t node);
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
324
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
325 /* Remove an element at a given position from the list.
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
326 POSITION must be >= 0 and < gl_list_size (list).
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
327 Return true. */
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
328 extern bool gl_list_remove_at (gl_list_t list, size_t position);
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
329
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
330 /* Search and remove an element from the list.
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
331 Return true if it was found and removed. */
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
332 extern bool gl_list_remove (gl_list_t list, const void *elt);
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
333
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
334 /* Free an entire list.
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
335 (But this call does not free the elements of the list.) */
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
336 extern void gl_list_free (gl_list_t list);
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
337
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
338 /* --------------------- gl_list_iterator_t Data Type --------------------- */
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
339
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
340 /* Functions for iterating through a list. */
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
341
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
342 /* Type of an iterator that traverses a list.
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
343 This is a fixed-size struct, so that creation of an iterator doesn't need
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
344 memory allocation on the heap. */
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
345 typedef struct
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
346 {
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
347 /* For fast dispatch of gl_list_iterator_next. */
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
348 const struct gl_list_implementation *vtable;
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
349 /* For detecting whether the last returned element was removed. */
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
350 gl_list_t list;
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
351 size_t count;
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
352 /* Other, implementation-private fields. */
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
353 void *p; void *q;
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
354 size_t i; size_t j;
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
355 } gl_list_iterator_t;
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
356
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
357 /* Create an iterator traversing a list.
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
358 The list contents must not be modified while the iterator is in use,
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
359 except for replacing or removing the last returned element. */
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
360 extern gl_list_iterator_t gl_list_iterator (gl_list_t list);
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
361
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
362 /* Create an iterator traversing the element with indices i,
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
363 start_index <= i < end_index, of a list.
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
364 The list contents must not be modified while the iterator is in use,
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
365 except for replacing or removing the last returned element. */
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
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
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
369
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
370 /* If there is a next element, store the next element in *ELTP, store its
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
371 node in *NODEP if NODEP is non-NULL, advance the iterator and return true.
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
372 Otherwise, return false. */
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
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
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
375
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
376 /* Free an iterator. */
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
377 extern void gl_list_iterator_free (gl_list_iterator_t *iterator);
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
378
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
379 /* ---------------------- Sorted gl_list_t Data Type ---------------------- */
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
380
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
381 /* The following functions are for lists without duplicates where the
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
382 order is given by a sort criterion. */
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
383
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
384 /* Type of function used to compare two elements. Same as for qsort().
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
385 NULL denotes pointer comparison. */
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
386 typedef int (*gl_listelement_compar_fn) (const void *elt1, const void *elt2);
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
387
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
388 /* Search whether an element is already in the list.
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
389 The list is assumed to be sorted with COMPAR.
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
390 Return its node if found, or NULL if not present in the list.
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
391 If the list contains several copies of ELT, the node of the leftmost one is
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
392 returned. */
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
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
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
396
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
397 /* Search whether an element is already in the list.
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
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
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
413 Return its position if found, or (size_t)(-1) if not present in the list.
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
414 If the list contains several copies of ELT, the position of the leftmost one
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
415 is returned. */
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
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
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
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
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
434 /* Add an element at the appropriate position in the list.
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
435 The list is assumed to be sorted with COMPAR.
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
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
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
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
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
450
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
451 /* Search and remove an element from the list.
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
452 The list is assumed to be sorted with COMPAR.
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
453 Return true if it was found and removed.
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
454 If the list contains several copies of ELT, only the leftmost one is
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
455 removed. */
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
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
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
459
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
460 /* ------------------------ Implementation Details ------------------------ */
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
461
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
462 struct gl_list_implementation
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
463 {
7554
579cface12e9 Pure ANSI C!
Bruno Haible <bruno@clisp.org>
parents: 7410
diff changeset
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
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
476 size_t (*size) (gl_list_t list);
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
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
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
480 gl_list_node_t (*next_node) (gl_list_t list, gl_list_node_t node);
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
481 gl_list_node_t (*previous_node) (gl_list_t list, gl_list_node_t node);
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
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
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
497 bool (*remove_node) (gl_list_t list, gl_list_node_t node);
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
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
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
500 void (*list_free) (gl_list_t list);
7554
579cface12e9 Pure ANSI C!
Bruno Haible <bruno@clisp.org>
parents: 7410
diff changeset
501 /* gl_list_iterator_t functions. */
6984
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
502 gl_list_iterator_t (*iterator) (gl_list_t list);
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
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
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
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
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
508 void (*iterator_free) (gl_list_iterator_t *iterator);
7554
579cface12e9 Pure ANSI C!
Bruno Haible <bruno@clisp.org>
parents: 7410
diff changeset
509 /* Sorted gl_list_t functions. */
6984
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
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
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
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
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
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
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
531 };
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
532
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
533 struct gl_list_impl_base
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
534 {
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
535 const struct gl_list_implementation *vtable;
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
536 gl_listelement_equals_fn equals_fn;
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
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
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
539 bool allow_duplicates;
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
540 };
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
541
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
542 #if HAVE_INLINE
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
543
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
544 /* Define all functions of this file as inline accesses to the
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
545 struct gl_list_implementation.
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
546 Use #define to avoid a warning because of extern vs. static. */
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
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
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
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
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
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
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
559 }
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
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
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
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
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
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
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
573 }
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
574
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
575 # define gl_list_size gl_list_size_inline
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
576 static inline size_t
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
577 gl_list_size (gl_list_t list)
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
578 {
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
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
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
581 }
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
582
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
583 # define gl_list_node_value gl_list_node_value_inline
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
584 static inline const void *
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
585 gl_list_node_value (gl_list_t list, gl_list_node_t node)
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
586 {
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
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
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
589 }
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
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
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
600 # define gl_list_next_node gl_list_next_node_inline
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
601 static inline gl_list_node_t
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
602 gl_list_next_node (gl_list_t list, gl_list_node_t node)
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
603 {
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
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
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
606 }
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
607
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
608 # define gl_list_previous_node gl_list_previous_node_inline
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
609 static inline gl_list_node_t
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
610 gl_list_previous_node (gl_list_t list, gl_list_node_t node)
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
611 {
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
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
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
614 }
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
615
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
616 # define gl_list_get_at gl_list_get_at_inline
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
617 static inline const void *
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
618 gl_list_get_at (gl_list_t list, size_t position)
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
619 {
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
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
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
622 }
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
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
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
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
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
627 {
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
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
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
630 }
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
631
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
632 # define gl_list_search gl_list_search_inline
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
633 static inline gl_list_node_t
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
634 gl_list_search (gl_list_t list, const void *elt)
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
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
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
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
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
657 }
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
658
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
659 # define gl_list_indexof gl_list_indexof_inline
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
660 static inline size_t
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
661 gl_list_indexof (gl_list_t list, const void *elt)
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
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
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
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
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
684 }
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
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
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
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
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
689 {
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
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
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
692 }
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
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
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
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
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
697 {
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
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
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
700 }
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
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
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
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
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
705 {
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
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
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
708 }
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
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
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
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
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
713 {
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
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
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
716 }
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
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
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
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
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
721 {
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
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
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
724 }
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
725
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
726 # define gl_list_remove_node gl_list_remove_node_inline
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
727 static inline bool
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
728 gl_list_remove_node (gl_list_t list, gl_list_node_t node)
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
729 {
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
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
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
732 }
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
733
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
734 # define gl_list_remove_at gl_list_remove_at_inline
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
735 static inline bool
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
736 gl_list_remove_at (gl_list_t list, size_t position)
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
737 {
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
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
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
740 }
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
741
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
742 # define gl_list_remove gl_list_remove_inline
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
743 static inline bool
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
744 gl_list_remove (gl_list_t list, const void *elt)
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
745 {
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
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
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
748 }
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
749
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
750 # define gl_list_free gl_list_free_inline
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
751 static inline void
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
752 gl_list_free (gl_list_t list)
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
753 {
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
754 ((const struct gl_list_impl_base *) list)->vtable->list_free (list);
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
755 }
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
756
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
757 # define gl_list_iterator gl_list_iterator_inline
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
758 static inline gl_list_iterator_t
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
759 gl_list_iterator (gl_list_t list)
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
760 {
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
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
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
763 }
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
764
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
765 # define gl_list_iterator_from_to gl_list_iterator_from_to_inline
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
766 static inline gl_list_iterator_t
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
767 gl_list_iterator_from_to (gl_list_t list, size_t start_index, size_t end_index)
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
768 {
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
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
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
771 }
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
772
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
773 # define gl_list_iterator_next gl_list_iterator_next_inline
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
774 static inline bool
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
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
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
777 {
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
778 return iterator->vtable->iterator_next (iterator, eltp, nodep);
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
779 }
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
780
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
781 # define gl_list_iterator_free gl_list_iterator_free_inline
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
782 static inline void
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
783 gl_list_iterator_free (gl_list_iterator_t *iterator)
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
784 {
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
785 iterator->vtable->iterator_free (iterator);
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
786 }
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
787
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
788 # define gl_sortedlist_search gl_sortedlist_search_inline
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
789 static inline gl_list_node_t
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
790 gl_sortedlist_search (gl_list_t list, gl_listelement_compar_fn compar, const void *elt)
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
791 {
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
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
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
794 }
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
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
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
805 # define gl_sortedlist_indexof gl_sortedlist_indexof_inline
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
806 static inline size_t
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
807 gl_sortedlist_indexof (gl_list_t list, gl_listelement_compar_fn compar, const void *elt)
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
808 {
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
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
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
811 }
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
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
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
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
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
825 {
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
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
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
828 }
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
829
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
830 # define gl_sortedlist_remove gl_sortedlist_remove_inline
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
831 static inline bool
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
832 gl_sortedlist_remove (gl_list_t list, gl_listelement_compar_fn compar, const void *elt)
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
833 {
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
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
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
836 }
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
837
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
838 #endif
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
839
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
840 #ifdef __cplusplus
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
841 }
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
842 #endif
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
843
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
844 #endif /* _GL_LIST_H */