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 return ((const struct gl_list_impl_base *) list)->vtable
101 gl_list_indexof (gl_list_t list, const void *elt)
103 return ((const struct gl_list_impl_base *) list)->vtable
104 ->indexof (list, elt);
108 gl_list_add_first (gl_list_t list, const void *elt)
110 return ((const struct gl_list_impl_base *) list)->vtable
111 ->add_first (list, elt);
115 gl_list_add_last (gl_list_t list, const void *elt)
117 return ((const struct gl_list_impl_base *) list)->vtable
118 ->add_last (list, elt);
122 gl_list_add_before (gl_list_t list, gl_list_node_t node, const void *elt)
124 return ((const struct gl_list_impl_base *) list)->vtable
125 ->add_before (list, node, elt);
129 gl_list_add_after (gl_list_t list, gl_list_node_t node, const void *elt)
131 return ((const struct gl_list_impl_base *) list)->vtable
132 ->add_after (list, node, elt);
136 gl_list_add_at (gl_list_t list, size_t position, const void *elt)
138 return ((const struct gl_list_impl_base *) list)->vtable
139 ->add_at (list, position, elt);
143 gl_list_remove_node (gl_list_t list, gl_list_node_t node)
145 return ((const struct gl_list_impl_base *) list)->vtable
146 ->remove_node (list, node);
150 gl_list_remove_at (gl_list_t list, size_t position)
152 return ((const struct gl_list_impl_base *) list)->vtable
153 ->remove_at (list, position);
157 gl_list_remove (gl_list_t list, const void *elt)
159 return ((const struct gl_list_impl_base *) list)->vtable
160 ->remove (list, elt);
164 gl_list_free (gl_list_t list)
166 ((const struct gl_list_impl_base *) list)->vtable->list_free (list);
170 gl_list_iterator (gl_list_t list)
172 return ((const struct gl_list_impl_base *) list)->vtable
177 gl_list_iterator_from_to (gl_list_t list, size_t start_index, size_t end_index)
179 return ((const struct gl_list_impl_base *) list)->vtable
180 ->iterator_from_to (list, start_index, end_index);
184 gl_list_iterator_next (gl_list_iterator_t *iterator,
185 const void **eltp, gl_list_node_t *nodep)
187 return iterator->vtable->iterator_next (iterator, eltp, nodep);
191 gl_list_iterator_free (gl_list_iterator_t *iterator)
193 iterator->vtable->iterator_free (iterator);
197 gl_sortedlist_search (gl_list_t list, gl_listelement_compar_fn compar, const void *elt)
199 return ((const struct gl_list_impl_base *) list)->vtable
200 ->sortedlist_search (list, compar, elt);
204 gl_sortedlist_indexof (gl_list_t list, gl_listelement_compar_fn compar, const void *elt)
206 return ((const struct gl_list_impl_base *) list)->vtable
207 ->sortedlist_indexof (list, compar, elt);
211 gl_sortedlist_add (gl_list_t list, gl_listelement_compar_fn compar, const void *elt)
213 return ((const struct gl_list_impl_base *) list)->vtable
214 ->sortedlist_add (list, compar, elt);
218 gl_sortedlist_remove (gl_list_t list, gl_listelement_compar_fn compar, const void *elt)
220 return ((const struct gl_list_impl_base *) list)->vtable
221 ->sortedlist_remove (list, compar, elt);