1 /* Abstract sequential list data type.
2 Copyright (C) 2006 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 2, or (at your option)
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, write to the Free Software Foundation,
17 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
26 /* Define all functions of this file as inline accesses to the
27 struct gl_list_implementation.
28 Use #define to avoid a warning because of extern vs. static. */
31 gl_list_create_empty (gl_list_implementation_t implementation,
32 gl_listelement_equals_fn equals_fn,
33 gl_listelement_hashcode_fn hashcode_fn,
34 bool allow_duplicates)
36 return implementation->create_empty (implementation, equals_fn, hashcode_fn,
41 gl_list_create (gl_list_implementation_t implementation,
42 gl_listelement_equals_fn equals_fn,
43 gl_listelement_hashcode_fn hashcode_fn,
44 bool allow_duplicates,
45 size_t count, const void **contents)
47 return implementation->create (implementation, equals_fn, hashcode_fn,
48 allow_duplicates, count, contents);
52 gl_list_size (gl_list_t list)
54 return ((const struct gl_list_impl_base *) list)->vtable
59 gl_list_node_value (gl_list_t list, gl_list_node_t node)
61 return ((const struct gl_list_impl_base *) list)->vtable
62 ->node_value (list, node);
66 gl_list_next_node (gl_list_t list, gl_list_node_t node)
68 return ((const struct gl_list_impl_base *) list)->vtable
69 ->next_node (list, node);
73 gl_list_previous_node (gl_list_t list, gl_list_node_t node)
75 return ((const struct gl_list_impl_base *) list)->vtable
76 ->previous_node (list, node);
80 gl_list_get_at (gl_list_t list, size_t position)
82 return ((const struct gl_list_impl_base *) list)->vtable
83 ->get_at (list, position);
87 gl_list_set_at (gl_list_t list, size_t position, const void *elt)
89 return ((const struct gl_list_impl_base *) list)->vtable
90 ->set_at (list, position, elt);
94 gl_list_search (gl_list_t list, const void *elt)
96 size_t size = ((const struct gl_list_impl_base *) list)->vtable->size (list);
97 return ((const struct gl_list_impl_base *) list)->vtable
98 ->search_from_to (list, 0, size, elt);
102 gl_list_search_from (gl_list_t list, size_t start_index, 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, start_index, size, elt);
110 gl_list_search_from_to (gl_list_t list, size_t start_index, size_t end_index, const void *elt)
112 return ((const struct gl_list_impl_base *) list)->vtable
113 ->search_from_to (list, start_index, end_index, elt);
117 gl_list_indexof (gl_list_t list, const void *elt)
119 size_t size = ((const struct gl_list_impl_base *) list)->vtable->size (list);
120 return ((const struct gl_list_impl_base *) list)->vtable
121 ->indexof_from_to (list, 0, size, elt);
125 gl_list_indexof_from (gl_list_t list, size_t start_index, 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, start_index, size, elt);
133 gl_list_indexof_from_to (gl_list_t list, size_t start_index, size_t end_index, const void *elt)
135 return ((const struct gl_list_impl_base *) list)->vtable
136 ->indexof_from_to (list, start_index, end_index, elt);
140 gl_list_add_first (gl_list_t list, const void *elt)
142 return ((const struct gl_list_impl_base *) list)->vtable
143 ->add_first (list, elt);
147 gl_list_add_last (gl_list_t list, const void *elt)
149 return ((const struct gl_list_impl_base *) list)->vtable
150 ->add_last (list, elt);
154 gl_list_add_before (gl_list_t list, gl_list_node_t node, const void *elt)
156 return ((const struct gl_list_impl_base *) list)->vtable
157 ->add_before (list, node, elt);
161 gl_list_add_after (gl_list_t list, gl_list_node_t node, const void *elt)
163 return ((const struct gl_list_impl_base *) list)->vtable
164 ->add_after (list, node, elt);
168 gl_list_add_at (gl_list_t list, size_t position, const void *elt)
170 return ((const struct gl_list_impl_base *) list)->vtable
171 ->add_at (list, position, elt);
175 gl_list_remove_node (gl_list_t list, gl_list_node_t node)
177 return ((const struct gl_list_impl_base *) list)->vtable
178 ->remove_node (list, node);
182 gl_list_remove_at (gl_list_t list, size_t position)
184 return ((const struct gl_list_impl_base *) list)->vtable
185 ->remove_at (list, position);
189 gl_list_remove (gl_list_t list, const void *elt)
191 return ((const struct gl_list_impl_base *) list)->vtable
192 ->remove (list, elt);
196 gl_list_free (gl_list_t list)
198 ((const struct gl_list_impl_base *) list)->vtable->list_free (list);
202 gl_list_iterator (gl_list_t list)
204 return ((const struct gl_list_impl_base *) list)->vtable
209 gl_list_iterator_from_to (gl_list_t list, size_t start_index, size_t end_index)
211 return ((const struct gl_list_impl_base *) list)->vtable
212 ->iterator_from_to (list, start_index, end_index);
216 gl_list_iterator_next (gl_list_iterator_t *iterator,
217 const void **eltp, gl_list_node_t *nodep)
219 return iterator->vtable->iterator_next (iterator, eltp, nodep);
223 gl_list_iterator_free (gl_list_iterator_t *iterator)
225 iterator->vtable->iterator_free (iterator);
229 gl_sortedlist_search (gl_list_t list, gl_listelement_compar_fn compar, const void *elt)
231 return ((const struct gl_list_impl_base *) list)->vtable
232 ->sortedlist_search (list, compar, elt);
236 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)
238 return ((const struct gl_list_impl_base *) list)->vtable
239 ->sortedlist_search_from_to (list, compar, start_index, end_index,
244 gl_sortedlist_indexof (gl_list_t list, gl_listelement_compar_fn compar, const void *elt)
246 return ((const struct gl_list_impl_base *) list)->vtable
247 ->sortedlist_indexof (list, compar, elt);
251 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)
253 return ((const struct gl_list_impl_base *) list)->vtable
254 ->sortedlist_indexof_from_to (list, compar, start_index, end_index,
259 gl_sortedlist_add (gl_list_t list, gl_listelement_compar_fn compar, const void *elt)
261 return ((const struct gl_list_impl_base *) list)->vtable
262 ->sortedlist_add (list, compar, elt);
266 gl_sortedlist_remove (gl_list_t list, gl_listelement_compar_fn compar, const void *elt)
268 return ((const struct gl_list_impl_base *) list)->vtable
269 ->sortedlist_remove (list, compar, elt);