1 /* Abstract sequential list data type.
2 Copyright (C) 2006-2008 Free Software Foundation, Inc.
3 Written by Bruno Haible <bruno@clisp.org>, 2006.
5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 3 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>. */
25 /* Define all functions of this file as inline accesses to the
26 struct gl_list_implementation.
27 Use #define to avoid a warning because of extern vs. static. */
30 gl_list_create_empty (gl_list_implementation_t implementation,
31 gl_listelement_equals_fn equals_fn,
32 gl_listelement_hashcode_fn hashcode_fn,
33 gl_listelement_dispose_fn dispose_fn,
34 bool allow_duplicates)
36 return implementation->create_empty (implementation, equals_fn, hashcode_fn,
37 dispose_fn, allow_duplicates);
41 gl_list_create (gl_list_implementation_t implementation,
42 gl_listelement_equals_fn equals_fn,
43 gl_listelement_hashcode_fn hashcode_fn,
44 gl_listelement_dispose_fn dispose_fn,
45 bool allow_duplicates,
46 size_t count, const void **contents)
48 return implementation->create (implementation, equals_fn, hashcode_fn,
49 dispose_fn, allow_duplicates, count, contents);
53 gl_list_size (gl_list_t list)
55 return ((const struct gl_list_impl_base *) list)->vtable
60 gl_list_node_value (gl_list_t list, gl_list_node_t node)
62 return ((const struct gl_list_impl_base *) list)->vtable
63 ->node_value (list, node);
67 gl_list_node_set_value (gl_list_t list, gl_list_node_t node, const void *elt)
69 ((const struct gl_list_impl_base *) list)->vtable
70 ->node_set_value (list, node, elt);
74 gl_list_next_node (gl_list_t list, gl_list_node_t node)
76 return ((const struct gl_list_impl_base *) list)->vtable
77 ->next_node (list, node);
81 gl_list_previous_node (gl_list_t list, gl_list_node_t node)
83 return ((const struct gl_list_impl_base *) list)->vtable
84 ->previous_node (list, node);
88 gl_list_get_at (gl_list_t list, size_t position)
90 return ((const struct gl_list_impl_base *) list)->vtable
91 ->get_at (list, position);
95 gl_list_set_at (gl_list_t list, size_t position, const void *elt)
97 return ((const struct gl_list_impl_base *) list)->vtable
98 ->set_at (list, position, elt);
102 gl_list_search (gl_list_t list, const void *elt)
104 size_t size = ((const struct gl_list_impl_base *) list)->vtable->size (list);
105 return ((const struct gl_list_impl_base *) list)->vtable
106 ->search_from_to (list, 0, size, elt);
110 gl_list_search_from (gl_list_t list, size_t start_index, const void *elt)
112 size_t size = ((const struct gl_list_impl_base *) list)->vtable->size (list);
113 return ((const struct gl_list_impl_base *) list)->vtable
114 ->search_from_to (list, start_index, size, elt);
118 gl_list_search_from_to (gl_list_t list, size_t start_index, size_t end_index, const void *elt)
120 return ((const struct gl_list_impl_base *) list)->vtable
121 ->search_from_to (list, start_index, end_index, elt);
125 gl_list_indexof (gl_list_t list, const void *elt)
127 size_t size = ((const struct gl_list_impl_base *) list)->vtable->size (list);
128 return ((const struct gl_list_impl_base *) list)->vtable
129 ->indexof_from_to (list, 0, size, elt);
133 gl_list_indexof_from (gl_list_t list, size_t start_index, const void *elt)
135 size_t size = ((const struct gl_list_impl_base *) list)->vtable->size (list);
136 return ((const struct gl_list_impl_base *) list)->vtable
137 ->indexof_from_to (list, start_index, size, elt);
141 gl_list_indexof_from_to (gl_list_t list, size_t start_index, size_t end_index, const void *elt)
143 return ((const struct gl_list_impl_base *) list)->vtable
144 ->indexof_from_to (list, start_index, end_index, elt);
148 gl_list_add_first (gl_list_t list, const void *elt)
150 return ((const struct gl_list_impl_base *) list)->vtable
151 ->add_first (list, elt);
155 gl_list_add_last (gl_list_t list, const void *elt)
157 return ((const struct gl_list_impl_base *) list)->vtable
158 ->add_last (list, elt);
162 gl_list_add_before (gl_list_t list, gl_list_node_t node, const void *elt)
164 return ((const struct gl_list_impl_base *) list)->vtable
165 ->add_before (list, node, elt);
169 gl_list_add_after (gl_list_t list, gl_list_node_t node, const void *elt)
171 return ((const struct gl_list_impl_base *) list)->vtable
172 ->add_after (list, node, elt);
176 gl_list_add_at (gl_list_t list, size_t position, const void *elt)
178 return ((const struct gl_list_impl_base *) list)->vtable
179 ->add_at (list, position, elt);
183 gl_list_remove_node (gl_list_t list, gl_list_node_t node)
185 return ((const struct gl_list_impl_base *) list)->vtable
186 ->remove_node (list, node);
190 gl_list_remove_at (gl_list_t list, size_t position)
192 return ((const struct gl_list_impl_base *) list)->vtable
193 ->remove_at (list, position);
197 gl_list_remove (gl_list_t list, const void *elt)
199 return ((const struct gl_list_impl_base *) list)->vtable
200 ->remove (list, elt);
204 gl_list_free (gl_list_t list)
206 ((const struct gl_list_impl_base *) list)->vtable->list_free (list);
210 gl_list_iterator (gl_list_t list)
212 return ((const struct gl_list_impl_base *) list)->vtable
217 gl_list_iterator_from_to (gl_list_t list, size_t start_index, size_t end_index)
219 return ((const struct gl_list_impl_base *) list)->vtable
220 ->iterator_from_to (list, start_index, end_index);
224 gl_list_iterator_next (gl_list_iterator_t *iterator,
225 const void **eltp, gl_list_node_t *nodep)
227 return iterator->vtable->iterator_next (iterator, eltp, nodep);
231 gl_list_iterator_free (gl_list_iterator_t *iterator)
233 iterator->vtable->iterator_free (iterator);
237 gl_sortedlist_search (gl_list_t list, gl_listelement_compar_fn compar, const void *elt)
239 return ((const struct gl_list_impl_base *) list)->vtable
240 ->sortedlist_search (list, compar, elt);
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)
246 return ((const struct gl_list_impl_base *) list)->vtable
247 ->sortedlist_search_from_to (list, compar, start_index, end_index,
252 gl_sortedlist_indexof (gl_list_t list, gl_listelement_compar_fn compar, const void *elt)
254 return ((const struct gl_list_impl_base *) list)->vtable
255 ->sortedlist_indexof (list, compar, elt);
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)
261 return ((const struct gl_list_impl_base *) list)->vtable
262 ->sortedlist_indexof_from_to (list, compar, start_index, end_index,
267 gl_sortedlist_add (gl_list_t list, gl_listelement_compar_fn compar, const void *elt)
269 return ((const struct gl_list_impl_base *) list)->vtable
270 ->sortedlist_add (list, compar, elt);
274 gl_sortedlist_remove (gl_list_t list, gl_listelement_compar_fn compar, const void *elt)
276 return ((const struct gl_list_impl_base *) list)->vtable
277 ->sortedlist_remove (list, compar, elt);