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. */
28 /* Define all functions of this file as inline accesses to the
29 struct gl_list_implementation.
30 Use #define to avoid a warning because of extern vs. static. */
33 gl_list_create_empty (gl_list_implementation_t implementation,
34 gl_listelement_equals_fn equals_fn,
35 gl_listelement_hashcode_fn hashcode_fn,
36 bool allow_duplicates)
38 return implementation->create_empty (implementation, equals_fn, hashcode_fn,
43 gl_list_create (gl_list_implementation_t implementation,
44 gl_listelement_equals_fn equals_fn,
45 gl_listelement_hashcode_fn hashcode_fn,
46 bool allow_duplicates,
47 size_t count, const void **contents)
49 return implementation->create (implementation, equals_fn, hashcode_fn,
50 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 return ((const struct gl_list_impl_base *) list)->vtable
103 gl_list_indexof (gl_list_t list, const void *elt)
105 return ((const struct gl_list_impl_base *) list)->vtable
106 ->indexof (list, elt);
110 gl_list_add_first (gl_list_t list, const void *elt)
112 return ((const struct gl_list_impl_base *) list)->vtable
113 ->add_first (list, elt);
117 gl_list_add_last (gl_list_t list, const void *elt)
119 return ((const struct gl_list_impl_base *) list)->vtable
120 ->add_last (list, elt);
124 gl_list_add_before (gl_list_t list, gl_list_node_t node, const void *elt)
126 return ((const struct gl_list_impl_base *) list)->vtable
127 ->add_before (list, node, elt);
131 gl_list_add_after (gl_list_t list, gl_list_node_t node, const void *elt)
133 return ((const struct gl_list_impl_base *) list)->vtable
134 ->add_after (list, node, elt);
138 gl_list_add_at (gl_list_t list, size_t position, const void *elt)
140 return ((const struct gl_list_impl_base *) list)->vtable
141 ->add_at (list, position, elt);
145 gl_list_remove_node (gl_list_t list, gl_list_node_t node)
147 return ((const struct gl_list_impl_base *) list)->vtable
148 ->remove_node (list, node);
152 gl_list_remove_at (gl_list_t list, size_t position)
154 return ((const struct gl_list_impl_base *) list)->vtable
155 ->remove_at (list, position);
159 gl_list_remove (gl_list_t list, const void *elt)
161 return ((const struct gl_list_impl_base *) list)->vtable
162 ->remove (list, elt);
166 gl_list_free (gl_list_t list)
168 ((const struct gl_list_impl_base *) list)->vtable->list_free (list);
172 gl_list_iterator (gl_list_t list)
174 return ((const struct gl_list_impl_base *) list)->vtable
179 gl_list_iterator_from_to (gl_list_t list, size_t start_index, size_t end_index)
181 return ((const struct gl_list_impl_base *) list)->vtable
182 ->iterator_from_to (list, start_index, end_index);
186 gl_list_iterator_next (gl_list_iterator_t *iterator,
187 const void **eltp, gl_list_node_t *nodep)
189 return iterator->vtable->iterator_next (iterator, eltp, nodep);
193 gl_list_iterator_free (gl_list_iterator_t *iterator)
195 iterator->vtable->iterator_free (iterator);
199 gl_sortedlist_search (gl_list_t list, gl_listelement_compar_fn compar, const void *elt)
201 return ((const struct gl_list_impl_base *) list)->vtable
202 ->sortedlist_search (list, compar, elt);
206 gl_sortedlist_indexof (gl_list_t list, gl_listelement_compar_fn compar, const void *elt)
208 return ((const struct gl_list_impl_base *) list)->vtable
209 ->sortedlist_indexof (list, compar, elt);
213 gl_sortedlist_add (gl_list_t list, gl_listelement_compar_fn compar, const void *elt)
215 return ((const struct gl_list_impl_base *) list)->vtable
216 ->sortedlist_add (list, compar, elt);
220 gl_sortedlist_remove (gl_list_t list, gl_listelement_compar_fn compar, const void *elt)
222 return ((const struct gl_list_impl_base *) list)->vtable
223 ->sortedlist_remove (list, compar, elt);