annotate lib/gl_list.c @ 10001:facc928673d7

Declare rpmatch.
author Bruno Haible <bruno@clisp.org>
date Tue, 29 Apr 2008 02:55:59 +0200
parents 25f7280c9cf0
children e0b4f68f21c2
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.
9686
25f7280c9cf0 New abstract list operation 'node_set_value'.
Bruno Haible <bruno@clisp.org>
parents: 9309
diff changeset
2 Copyright (C) 2006-2008 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
7304
1c4ed7637c24 Include <config.h> unconditionally.
Bruno Haible <bruno@clisp.org>
parents: 6984
diff changeset
18 #include <config.h>
6984
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
19
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
20 /* Specification. */
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
21 #include "gl_list.h"
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
22
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
23 #if !HAVE_INLINE
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
24
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
25 /* Define all functions of this file as inline accesses to the
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
26 struct gl_list_implementation.
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
27 Use #define to avoid a warning because of extern vs. static. */
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_t
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
30 gl_list_create_empty (gl_list_implementation_t implementation,
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
31 gl_listelement_equals_fn equals_fn,
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
32 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: 7410
diff changeset
33 gl_listelement_dispose_fn dispose_fn,
6984
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
34 bool allow_duplicates)
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
35 {
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
36 return implementation->create_empty (implementation, equals_fn, hashcode_fn,
8438
238942284e2f Allow the use of a destructor for the values stored in the list.
Bruno Haible <bruno@clisp.org>
parents: 7410
diff changeset
37 dispose_fn, allow_duplicates);
6984
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
38 }
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
39
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
40 gl_list_t
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
41 gl_list_create (gl_list_implementation_t implementation,
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
42 gl_listelement_equals_fn equals_fn,
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
43 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: 7410
diff changeset
44 gl_listelement_dispose_fn dispose_fn,
6984
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
45 bool allow_duplicates,
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
46 size_t count, const void **contents)
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
47 {
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
48 return implementation->create (implementation, equals_fn, hashcode_fn,
8438
238942284e2f Allow the use of a destructor for the values stored in the list.
Bruno Haible <bruno@clisp.org>
parents: 7410
diff changeset
49 dispose_fn, allow_duplicates, count, contents);
6984
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
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
52 size_t
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
53 gl_list_size (gl_list_t list)
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
54 {
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
55 return ((const struct gl_list_impl_base *) list)->vtable
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
56 ->size (list);
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
57 }
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 const void *
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
60 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
61 {
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
62 return ((const struct gl_list_impl_base *) list)->vtable
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
63 ->node_value (list, node);
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
64 }
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
65
9686
25f7280c9cf0 New abstract list operation 'node_set_value'.
Bruno Haible <bruno@clisp.org>
parents: 9309
diff changeset
66 void
25f7280c9cf0 New abstract list operation 'node_set_value'.
Bruno Haible <bruno@clisp.org>
parents: 9309
diff changeset
67 gl_list_node_set_value (gl_list_t list, gl_list_node_t node, const void *elt)
25f7280c9cf0 New abstract list operation 'node_set_value'.
Bruno Haible <bruno@clisp.org>
parents: 9309
diff changeset
68 {
25f7280c9cf0 New abstract list operation 'node_set_value'.
Bruno Haible <bruno@clisp.org>
parents: 9309
diff changeset
69 ((const struct gl_list_impl_base *) list)->vtable
25f7280c9cf0 New abstract list operation 'node_set_value'.
Bruno Haible <bruno@clisp.org>
parents: 9309
diff changeset
70 ->node_set_value (list, node, elt);
25f7280c9cf0 New abstract list operation 'node_set_value'.
Bruno Haible <bruno@clisp.org>
parents: 9309
diff changeset
71 }
25f7280c9cf0 New abstract list operation 'node_set_value'.
Bruno Haible <bruno@clisp.org>
parents: 9309
diff changeset
72
6984
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
73 gl_list_node_t
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
74 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
75 {
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
76 return ((const struct gl_list_impl_base *) list)->vtable
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
77 ->next_node (list, node);
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
78 }
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
79
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
80 gl_list_node_t
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
81 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
82 {
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
83 return ((const struct gl_list_impl_base *) list)->vtable
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
84 ->previous_node (list, node);
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
85 }
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
86
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
87 const void *
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
88 gl_list_get_at (gl_list_t list, size_t position)
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
89 {
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
90 return ((const struct gl_list_impl_base *) list)->vtable
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
91 ->get_at (list, position);
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
92 }
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 gl_list_node_t
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
95 gl_list_set_at (gl_list_t list, size_t position, const void *elt)
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 return ((const struct gl_list_impl_base *) list)->vtable
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
98 ->set_at (list, position, elt);
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
99 }
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 gl_list_node_t
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
102 gl_list_search (gl_list_t list, const void *elt)
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
103 {
7405
0de49c40e105 Add searching operations, limited to a subsequence of the list.
Bruno Haible <bruno@clisp.org>
parents: 7304
diff changeset
104 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
105 return ((const struct gl_list_impl_base *) list)->vtable
7405
0de49c40e105 Add searching operations, limited to a subsequence of the list.
Bruno Haible <bruno@clisp.org>
parents: 7304
diff changeset
106 ->search_from_to (list, 0, size, elt);
0de49c40e105 Add searching operations, limited to a subsequence of the list.
Bruno Haible <bruno@clisp.org>
parents: 7304
diff changeset
107 }
0de49c40e105 Add searching operations, limited to a subsequence of the list.
Bruno Haible <bruno@clisp.org>
parents: 7304
diff changeset
108
0de49c40e105 Add searching operations, limited to a subsequence of the list.
Bruno Haible <bruno@clisp.org>
parents: 7304
diff changeset
109 gl_list_node_t
0de49c40e105 Add searching operations, limited to a subsequence of the list.
Bruno Haible <bruno@clisp.org>
parents: 7304
diff changeset
110 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: 7304
diff changeset
111 {
0de49c40e105 Add searching operations, limited to a subsequence of the list.
Bruno Haible <bruno@clisp.org>
parents: 7304
diff changeset
112 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: 7304
diff changeset
113 return ((const struct gl_list_impl_base *) list)->vtable
0de49c40e105 Add searching operations, limited to a subsequence of the list.
Bruno Haible <bruno@clisp.org>
parents: 7304
diff changeset
114 ->search_from_to (list, start_index, size, elt);
0de49c40e105 Add searching operations, limited to a subsequence of the list.
Bruno Haible <bruno@clisp.org>
parents: 7304
diff changeset
115 }
0de49c40e105 Add searching operations, limited to a subsequence of the list.
Bruno Haible <bruno@clisp.org>
parents: 7304
diff changeset
116
0de49c40e105 Add searching operations, limited to a subsequence of the list.
Bruno Haible <bruno@clisp.org>
parents: 7304
diff changeset
117 gl_list_node_t
0de49c40e105 Add searching operations, limited to a subsequence of the list.
Bruno Haible <bruno@clisp.org>
parents: 7304
diff changeset
118 gl_list_search_from_to (gl_list_t list, size_t start_index, size_t end_index, const void *elt)
0de49c40e105 Add searching operations, limited to a subsequence of the list.
Bruno Haible <bruno@clisp.org>
parents: 7304
diff changeset
119 {
0de49c40e105 Add searching operations, limited to a subsequence of the list.
Bruno Haible <bruno@clisp.org>
parents: 7304
diff changeset
120 return ((const struct gl_list_impl_base *) list)->vtable
0de49c40e105 Add searching operations, limited to a subsequence of the list.
Bruno Haible <bruno@clisp.org>
parents: 7304
diff changeset
121 ->search_from_to (list, start_index, end_index, elt);
6984
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
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
124 size_t
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
125 gl_list_indexof (gl_list_t list, const void *elt)
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
126 {
7405
0de49c40e105 Add searching operations, limited to a subsequence of the list.
Bruno Haible <bruno@clisp.org>
parents: 7304
diff changeset
127 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
128 return ((const struct gl_list_impl_base *) list)->vtable
7405
0de49c40e105 Add searching operations, limited to a subsequence of the list.
Bruno Haible <bruno@clisp.org>
parents: 7304
diff changeset
129 ->indexof_from_to (list, 0, size, elt);
0de49c40e105 Add searching operations, limited to a subsequence of the list.
Bruno Haible <bruno@clisp.org>
parents: 7304
diff changeset
130 }
0de49c40e105 Add searching operations, limited to a subsequence of the list.
Bruno Haible <bruno@clisp.org>
parents: 7304
diff changeset
131
0de49c40e105 Add searching operations, limited to a subsequence of the list.
Bruno Haible <bruno@clisp.org>
parents: 7304
diff changeset
132 size_t
0de49c40e105 Add searching operations, limited to a subsequence of the list.
Bruno Haible <bruno@clisp.org>
parents: 7304
diff changeset
133 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: 7304
diff changeset
134 {
0de49c40e105 Add searching operations, limited to a subsequence of the list.
Bruno Haible <bruno@clisp.org>
parents: 7304
diff changeset
135 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: 7304
diff changeset
136 return ((const struct gl_list_impl_base *) list)->vtable
0de49c40e105 Add searching operations, limited to a subsequence of the list.
Bruno Haible <bruno@clisp.org>
parents: 7304
diff changeset
137 ->indexof_from_to (list, start_index, size, elt);
0de49c40e105 Add searching operations, limited to a subsequence of the list.
Bruno Haible <bruno@clisp.org>
parents: 7304
diff changeset
138 }
0de49c40e105 Add searching operations, limited to a subsequence of the list.
Bruno Haible <bruno@clisp.org>
parents: 7304
diff changeset
139
0de49c40e105 Add searching operations, limited to a subsequence of the list.
Bruno Haible <bruno@clisp.org>
parents: 7304
diff changeset
140 size_t
0de49c40e105 Add searching operations, limited to a subsequence of the list.
Bruno Haible <bruno@clisp.org>
parents: 7304
diff changeset
141 gl_list_indexof_from_to (gl_list_t list, size_t start_index, size_t end_index, const void *elt)
0de49c40e105 Add searching operations, limited to a subsequence of the list.
Bruno Haible <bruno@clisp.org>
parents: 7304
diff changeset
142 {
0de49c40e105 Add searching operations, limited to a subsequence of the list.
Bruno Haible <bruno@clisp.org>
parents: 7304
diff changeset
143 return ((const struct gl_list_impl_base *) list)->vtable
0de49c40e105 Add searching operations, limited to a subsequence of the list.
Bruno Haible <bruno@clisp.org>
parents: 7304
diff changeset
144 ->indexof_from_to (list, start_index, end_index, elt);
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
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
147 gl_list_node_t
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
148 gl_list_add_first (gl_list_t list, const void *elt)
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
149 {
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
150 return ((const struct gl_list_impl_base *) list)->vtable
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
151 ->add_first (list, elt);
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
152 }
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
153
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
154 gl_list_node_t
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
155 gl_list_add_last (gl_list_t list, const void *elt)
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
156 {
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
157 return ((const struct gl_list_impl_base *) list)->vtable
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
158 ->add_last (list, elt);
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
159 }
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
160
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
161 gl_list_node_t
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
162 gl_list_add_before (gl_list_t list, gl_list_node_t node, const void *elt)
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
163 {
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
164 return ((const struct gl_list_impl_base *) list)->vtable
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
165 ->add_before (list, node, elt);
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
166 }
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
167
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
168 gl_list_node_t
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
169 gl_list_add_after (gl_list_t list, gl_list_node_t node, const void *elt)
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
170 {
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
171 return ((const struct gl_list_impl_base *) list)->vtable
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
172 ->add_after (list, node, elt);
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
173 }
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
174
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
175 gl_list_node_t
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
176 gl_list_add_at (gl_list_t list, size_t position, const void *elt)
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
177 {
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
178 return ((const struct gl_list_impl_base *) list)->vtable
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
179 ->add_at (list, position, elt);
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
180 }
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
181
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
182 bool
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
183 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
184 {
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
185 return ((const struct gl_list_impl_base *) list)->vtable
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
186 ->remove_node (list, node);
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
187 }
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
188
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
189 bool
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
190 gl_list_remove_at (gl_list_t list, size_t position)
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
191 {
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
192 return ((const struct gl_list_impl_base *) list)->vtable
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
193 ->remove_at (list, position);
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
194 }
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 bool
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
197 gl_list_remove (gl_list_t list, const void *elt)
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
198 {
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
199 return ((const struct gl_list_impl_base *) list)->vtable
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
200 ->remove (list, elt);
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
201 }
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
202
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
203 void
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
204 gl_list_free (gl_list_t list)
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
205 {
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
206 ((const struct gl_list_impl_base *) list)->vtable->list_free (list);
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
207 }
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
208
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
209 gl_list_iterator_t
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
210 gl_list_iterator (gl_list_t list)
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
211 {
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
212 return ((const struct gl_list_impl_base *) list)->vtable
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
213 ->iterator (list);
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
214 }
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
215
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
216 gl_list_iterator_t
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
217 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
218 {
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
219 return ((const struct gl_list_impl_base *) list)->vtable
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
220 ->iterator_from_to (list, start_index, end_index);
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
221 }
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
222
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
223 bool
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
224 gl_list_iterator_next (gl_list_iterator_t *iterator,
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
225 const void **eltp, gl_list_node_t *nodep)
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
226 {
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
227 return iterator->vtable->iterator_next (iterator, eltp, nodep);
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
228 }
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
229
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
230 void
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
231 gl_list_iterator_free (gl_list_iterator_t *iterator)
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
232 {
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
233 iterator->vtable->iterator_free (iterator);
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
234 }
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
235
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
236 gl_list_node_t
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
237 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
238 {
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
239 return ((const struct gl_list_impl_base *) list)->vtable
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
240 ->sortedlist_search (list, compar, elt);
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
241 }
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
242
7410
9704ff2cbdfe Add bounded list search operations.
Bruno Haible <bruno@clisp.org>
parents: 7405
diff changeset
243 gl_list_node_t
9704ff2cbdfe Add bounded list search operations.
Bruno Haible <bruno@clisp.org>
parents: 7405
diff changeset
244 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
245 {
9704ff2cbdfe Add bounded list search operations.
Bruno Haible <bruno@clisp.org>
parents: 7405
diff changeset
246 return ((const struct gl_list_impl_base *) list)->vtable
9704ff2cbdfe Add bounded list search operations.
Bruno Haible <bruno@clisp.org>
parents: 7405
diff changeset
247 ->sortedlist_search_from_to (list, compar, start_index, end_index,
9704ff2cbdfe Add bounded list search operations.
Bruno Haible <bruno@clisp.org>
parents: 7405
diff changeset
248 elt);
9704ff2cbdfe Add bounded list search operations.
Bruno Haible <bruno@clisp.org>
parents: 7405
diff changeset
249 }
9704ff2cbdfe Add bounded list search operations.
Bruno Haible <bruno@clisp.org>
parents: 7405
diff changeset
250
6984
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
251 size_t
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
252 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
253 {
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
254 return ((const struct gl_list_impl_base *) list)->vtable
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
255 ->sortedlist_indexof (list, compar, elt);
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
256 }
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
257
7410
9704ff2cbdfe Add bounded list search operations.
Bruno Haible <bruno@clisp.org>
parents: 7405
diff changeset
258 size_t
9704ff2cbdfe Add bounded list search operations.
Bruno Haible <bruno@clisp.org>
parents: 7405
diff changeset
259 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
260 {
9704ff2cbdfe Add bounded list search operations.
Bruno Haible <bruno@clisp.org>
parents: 7405
diff changeset
261 return ((const struct gl_list_impl_base *) list)->vtable
9704ff2cbdfe Add bounded list search operations.
Bruno Haible <bruno@clisp.org>
parents: 7405
diff changeset
262 ->sortedlist_indexof_from_to (list, compar, start_index, end_index,
9704ff2cbdfe Add bounded list search operations.
Bruno Haible <bruno@clisp.org>
parents: 7405
diff changeset
263 elt);
9704ff2cbdfe Add bounded list search operations.
Bruno Haible <bruno@clisp.org>
parents: 7405
diff changeset
264 }
9704ff2cbdfe Add bounded list search operations.
Bruno Haible <bruno@clisp.org>
parents: 7405
diff changeset
265
6984
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
266 gl_list_node_t
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
267 gl_sortedlist_add (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
268 {
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
269 return ((const struct gl_list_impl_base *) list)->vtable
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
270 ->sortedlist_add (list, compar, elt);
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
271 }
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
272
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
273 bool
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
274 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
275 {
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
276 return ((const struct gl_list_impl_base *) list)->vtable
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
277 ->sortedlist_remove (list, compar, elt);
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
278 }
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
279
416726372f54 Abstract list data type.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
280 #endif