1 /* Abstract sequential list data type.
2 Copyright (C) 2006-2007 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 gl_listelement_dispose_fn dispose_fn,
35 bool allow_duplicates)
37 return implementation->create_empty (implementation, equals_fn, hashcode_fn,
38 dispose_fn, allow_duplicates);
42 gl_list_create (gl_list_implementation_t implementation,
43 gl_listelement_equals_fn equals_fn,
44 gl_listelement_hashcode_fn hashcode_fn,
45 gl_listelement_dispose_fn dispose_fn,
46 bool allow_duplicates,
47 size_t count, const void **contents)
49 return implementation->create (implementation, equals_fn, hashcode_fn,
50 dispose_fn, allow_duplicates, count, contents);
54 gl_list_size (gl_list_t list)
56 return ((const struct gl_list_impl_base *) list)->vtable
61 gl_list_node_value (gl_list_t list, gl_list_node_t node)
63 return ((const struct gl_list_impl_base *) list)->vtable
64 ->node_value (list, node);
68 gl_list_next_node (gl_list_t list, gl_list_node_t node)
70 return ((const struct gl_list_impl_base *) list)->vtable
71 ->next_node (list, node);
75 gl_list_previous_node (gl_list_t list, gl_list_node_t node)
77 return ((const struct gl_list_impl_base *) list)->vtable
78 ->previous_node (list, node);
82 gl_list_get_at (gl_list_t list, size_t position)
84 return ((const struct gl_list_impl_base *) list)->vtable
85 ->get_at (list, position);
89 gl_list_set_at (gl_list_t list, size_t position, const void *elt)
91 return ((const struct gl_list_impl_base *) list)->vtable
92 ->set_at (list, position, elt);
96 gl_list_search (gl_list_t list, const void *elt)
98 size_t size = ((const struct gl_list_impl_base *) list)->vtable->size (list);
99 return ((const struct gl_list_impl_base *) list)->vtable
100 ->search_from_to (list, 0, size, elt);
104 gl_list_search_from (gl_list_t list, size_t start_index, const void *elt)
106 size_t size = ((const struct gl_list_impl_base *) list)->vtable->size (list);
107 return ((const struct gl_list_impl_base *) list)->vtable
108 ->search_from_to (list, start_index, size, elt);
112 gl_list_search_from_to (gl_list_t list, size_t start_index, size_t end_index, const void *elt)
114 return ((const struct gl_list_impl_base *) list)->vtable
115 ->search_from_to (list, start_index, end_index, elt);
119 gl_list_indexof (gl_list_t list, const void *elt)
121 size_t size = ((const struct gl_list_impl_base *) list)->vtable->size (list);
122 return ((const struct gl_list_impl_base *) list)->vtable
123 ->indexof_from_to (list, 0, size, elt);
127 gl_list_indexof_from (gl_list_t list, size_t start_index, const void *elt)
129 size_t size = ((const struct gl_list_impl_base *) list)->vtable->size (list);
130 return ((const struct gl_list_impl_base *) list)->vtable
131 ->indexof_from_to (list, start_index, size, elt);
135 gl_list_indexof_from_to (gl_list_t list, size_t start_index, size_t end_index, const void *elt)
137 return ((const struct gl_list_impl_base *) list)->vtable
138 ->indexof_from_to (list, start_index, end_index, elt);
142 gl_list_add_first (gl_list_t list, const void *elt)
144 return ((const struct gl_list_impl_base *) list)->vtable
145 ->add_first (list, elt);
149 gl_list_add_last (gl_list_t list, const void *elt)
151 return ((const struct gl_list_impl_base *) list)->vtable
152 ->add_last (list, elt);
156 gl_list_add_before (gl_list_t list, gl_list_node_t node, const void *elt)
158 return ((const struct gl_list_impl_base *) list)->vtable
159 ->add_before (list, node, elt);
163 gl_list_add_after (gl_list_t list, gl_list_node_t node, const void *elt)
165 return ((const struct gl_list_impl_base *) list)->vtable
166 ->add_after (list, node, elt);
170 gl_list_add_at (gl_list_t list, size_t position, const void *elt)
172 return ((const struct gl_list_impl_base *) list)->vtable
173 ->add_at (list, position, elt);
177 gl_list_remove_node (gl_list_t list, gl_list_node_t node)
179 return ((const struct gl_list_impl_base *) list)->vtable
180 ->remove_node (list, node);
184 gl_list_remove_at (gl_list_t list, size_t position)
186 return ((const struct gl_list_impl_base *) list)->vtable
187 ->remove_at (list, position);
191 gl_list_remove (gl_list_t list, const void *elt)
193 return ((const struct gl_list_impl_base *) list)->vtable
194 ->remove (list, elt);
198 gl_list_free (gl_list_t list)
200 ((const struct gl_list_impl_base *) list)->vtable->list_free (list);
204 gl_list_iterator (gl_list_t list)
206 return ((const struct gl_list_impl_base *) list)->vtable
211 gl_list_iterator_from_to (gl_list_t list, size_t start_index, size_t end_index)
213 return ((const struct gl_list_impl_base *) list)->vtable
214 ->iterator_from_to (list, start_index, end_index);
218 gl_list_iterator_next (gl_list_iterator_t *iterator,
219 const void **eltp, gl_list_node_t *nodep)
221 return iterator->vtable->iterator_next (iterator, eltp, nodep);
225 gl_list_iterator_free (gl_list_iterator_t *iterator)
227 iterator->vtable->iterator_free (iterator);
231 gl_sortedlist_search (gl_list_t list, gl_listelement_compar_fn compar, const void *elt)
233 return ((const struct gl_list_impl_base *) list)->vtable
234 ->sortedlist_search (list, compar, elt);
238 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)
240 return ((const struct gl_list_impl_base *) list)->vtable
241 ->sortedlist_search_from_to (list, compar, start_index, end_index,
246 gl_sortedlist_indexof (gl_list_t list, gl_listelement_compar_fn compar, const void *elt)
248 return ((const struct gl_list_impl_base *) list)->vtable
249 ->sortedlist_indexof (list, compar, elt);
253 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)
255 return ((const struct gl_list_impl_base *) list)->vtable
256 ->sortedlist_indexof_from_to (list, compar, start_index, end_index,
261 gl_sortedlist_add (gl_list_t list, gl_listelement_compar_fn compar, const void *elt)
263 return ((const struct gl_list_impl_base *) list)->vtable
264 ->sortedlist_add (list, compar, elt);
268 gl_sortedlist_remove (gl_list_t list, gl_listelement_compar_fn compar, const void *elt)
270 return ((const struct gl_list_impl_base *) list)->vtable
271 ->sortedlist_remove (list, compar, elt);