1 /* Abstract sequential list data type.
2 Copyright (C) 2006-2011 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_nx_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->nx_create_empty (implementation, equals_fn,
37 hashcode_fn, dispose_fn,
42 gl_list_nx_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->nx_create (implementation, equals_fn, hashcode_fn,
50 dispose_fn, allow_duplicates, count,
55 gl_list_size (gl_list_t list)
57 return ((const struct gl_list_impl_base *) list)->vtable
62 gl_list_node_value (gl_list_t list, gl_list_node_t node)
64 return ((const struct gl_list_impl_base *) list)->vtable
65 ->node_value (list, node);
69 gl_list_node_nx_set_value (gl_list_t list, gl_list_node_t node,
72 return ((const struct gl_list_impl_base *) list)->vtable
73 ->node_nx_set_value (list, node, elt);
77 gl_list_next_node (gl_list_t list, gl_list_node_t node)
79 return ((const struct gl_list_impl_base *) list)->vtable
80 ->next_node (list, node);
84 gl_list_previous_node (gl_list_t list, gl_list_node_t node)
86 return ((const struct gl_list_impl_base *) list)->vtable
87 ->previous_node (list, node);
91 gl_list_get_at (gl_list_t list, size_t position)
93 return ((const struct gl_list_impl_base *) list)->vtable
94 ->get_at (list, position);
98 gl_list_nx_set_at (gl_list_t list, size_t position, const void *elt)
100 return ((const struct gl_list_impl_base *) list)->vtable
101 ->nx_set_at (list, position, elt);
105 gl_list_search (gl_list_t list, const void *elt)
107 size_t size = ((const struct gl_list_impl_base *) list)->vtable->size (list);
108 return ((const struct gl_list_impl_base *) list)->vtable
109 ->search_from_to (list, 0, size, elt);
113 gl_list_search_from (gl_list_t list, size_t start_index, const void *elt)
115 size_t size = ((const struct gl_list_impl_base *) list)->vtable->size (list);
116 return ((const struct gl_list_impl_base *) list)->vtable
117 ->search_from_to (list, start_index, size, elt);
121 gl_list_search_from_to (gl_list_t list, size_t start_index, size_t end_index, const void *elt)
123 return ((const struct gl_list_impl_base *) list)->vtable
124 ->search_from_to (list, start_index, end_index, elt);
128 gl_list_indexof (gl_list_t list, const void *elt)
130 size_t size = ((const struct gl_list_impl_base *) list)->vtable->size (list);
131 return ((const struct gl_list_impl_base *) list)->vtable
132 ->indexof_from_to (list, 0, size, elt);
136 gl_list_indexof_from (gl_list_t list, size_t start_index, const void *elt)
138 size_t size = ((const struct gl_list_impl_base *) list)->vtable->size (list);
139 return ((const struct gl_list_impl_base *) list)->vtable
140 ->indexof_from_to (list, start_index, size, elt);
144 gl_list_indexof_from_to (gl_list_t list, size_t start_index, size_t end_index, const void *elt)
146 return ((const struct gl_list_impl_base *) list)->vtable
147 ->indexof_from_to (list, start_index, end_index, elt);
151 gl_list_nx_add_first (gl_list_t list, const void *elt)
153 return ((const struct gl_list_impl_base *) list)->vtable
154 ->nx_add_first (list, elt);
158 gl_list_nx_add_last (gl_list_t list, const void *elt)
160 return ((const struct gl_list_impl_base *) list)->vtable
161 ->nx_add_last (list, elt);
165 gl_list_nx_add_before (gl_list_t list, gl_list_node_t node, const void *elt)
167 return ((const struct gl_list_impl_base *) list)->vtable
168 ->nx_add_before (list, node, elt);
172 gl_list_nx_add_after (gl_list_t list, gl_list_node_t node, const void *elt)
174 return ((const struct gl_list_impl_base *) list)->vtable
175 ->nx_add_after (list, node, elt);
179 gl_list_nx_add_at (gl_list_t list, size_t position, const void *elt)
181 return ((const struct gl_list_impl_base *) list)->vtable
182 ->nx_add_at (list, position, elt);
186 gl_list_remove_node (gl_list_t list, gl_list_node_t node)
188 return ((const struct gl_list_impl_base *) list)->vtable
189 ->remove_node (list, node);
193 gl_list_remove_at (gl_list_t list, size_t position)
195 return ((const struct gl_list_impl_base *) list)->vtable
196 ->remove_at (list, position);
200 gl_list_remove (gl_list_t list, const void *elt)
202 return ((const struct gl_list_impl_base *) list)->vtable
203 ->remove_elt (list, elt);
207 gl_list_free (gl_list_t list)
209 ((const struct gl_list_impl_base *) list)->vtable->list_free (list);
213 gl_list_iterator (gl_list_t list)
215 return ((const struct gl_list_impl_base *) list)->vtable
220 gl_list_iterator_from_to (gl_list_t list, size_t start_index, size_t end_index)
222 return ((const struct gl_list_impl_base *) list)->vtable
223 ->iterator_from_to (list, start_index, end_index);
227 gl_list_iterator_next (gl_list_iterator_t *iterator,
228 const void **eltp, gl_list_node_t *nodep)
230 return iterator->vtable->iterator_next (iterator, eltp, nodep);
234 gl_list_iterator_free (gl_list_iterator_t *iterator)
236 iterator->vtable->iterator_free (iterator);
240 gl_sortedlist_search (gl_list_t list, gl_listelement_compar_fn compar, const void *elt)
242 return ((const struct gl_list_impl_base *) list)->vtable
243 ->sortedlist_search (list, compar, elt);
247 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)
249 return ((const struct gl_list_impl_base *) list)->vtable
250 ->sortedlist_search_from_to (list, compar, start_index, end_index,
255 gl_sortedlist_indexof (gl_list_t list, gl_listelement_compar_fn compar, const void *elt)
257 return ((const struct gl_list_impl_base *) list)->vtable
258 ->sortedlist_indexof (list, compar, elt);
262 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)
264 return ((const struct gl_list_impl_base *) list)->vtable
265 ->sortedlist_indexof_from_to (list, compar, start_index, end_index,
270 gl_sortedlist_nx_add (gl_list_t list, gl_listelement_compar_fn compar, const void *elt)
272 return ((const struct gl_list_impl_base *) list)->vtable
273 ->sortedlist_nx_add (list, compar, elt);
277 gl_sortedlist_remove (gl_list_t list, gl_listelement_compar_fn compar, const void *elt)
279 return ((const struct gl_list_impl_base *) list)->vtable
280 ->sortedlist_remove (list, compar, elt);