• Home
  • History
  • Annotate
  • Line#
  • Navigate
  • Raw
  • Download
  • only in /netgear-WNDR4500v2-V1.0.0.60_1.0.38/ap/gpl/timemachine/gettext-0.17/gettext-tools/gnulib-lib/
1/* Abstract sequential list data type.
2   Copyright (C) 2006-2007 Free Software Foundation, Inc.
3   Written by Bruno Haible <bruno@clisp.org>, 2006.
4
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.
9
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.
14
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/>.  */
17
18#include <config.h>
19
20/* Specification.  */
21#include "gl_list.h"
22
23#if !HAVE_INLINE
24
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.  */
28
29gl_list_t
30gl_list_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)
35{
36  return implementation->create_empty (implementation, equals_fn, hashcode_fn,
37				       dispose_fn, allow_duplicates);
38}
39
40gl_list_t
41gl_list_create (gl_list_implementation_t implementation,
42		gl_listelement_equals_fn equals_fn,
43		gl_listelement_hashcode_fn hashcode_fn,
44		gl_listelement_dispose_fn dispose_fn,
45		bool allow_duplicates,
46		size_t count, const void **contents)
47{
48  return implementation->create (implementation, equals_fn, hashcode_fn,
49				 dispose_fn, allow_duplicates, count, contents);
50}
51
52size_t
53gl_list_size (gl_list_t list)
54{
55  return ((const struct gl_list_impl_base *) list)->vtable
56	 ->size (list);
57}
58
59const void *
60gl_list_node_value (gl_list_t list, gl_list_node_t node)
61{
62  return ((const struct gl_list_impl_base *) list)->vtable
63	 ->node_value (list, node);
64}
65
66gl_list_node_t
67gl_list_next_node (gl_list_t list, gl_list_node_t node)
68{
69  return ((const struct gl_list_impl_base *) list)->vtable
70	 ->next_node (list, node);
71}
72
73gl_list_node_t
74gl_list_previous_node (gl_list_t list, gl_list_node_t node)
75{
76  return ((const struct gl_list_impl_base *) list)->vtable
77	 ->previous_node (list, node);
78}
79
80const void *
81gl_list_get_at (gl_list_t list, size_t position)
82{
83  return ((const struct gl_list_impl_base *) list)->vtable
84	 ->get_at (list, position);
85}
86
87gl_list_node_t
88gl_list_set_at (gl_list_t list, size_t position, const void *elt)
89{
90  return ((const struct gl_list_impl_base *) list)->vtable
91	 ->set_at (list, position, elt);
92}
93
94gl_list_node_t
95gl_list_search (gl_list_t list, const void *elt)
96{
97  size_t size = ((const struct gl_list_impl_base *) list)->vtable->size (list);
98  return ((const struct gl_list_impl_base *) list)->vtable
99	 ->search_from_to (list, 0, size, elt);
100}
101
102gl_list_node_t
103gl_list_search_from (gl_list_t list, size_t start_index, const void *elt)
104{
105  size_t size = ((const struct gl_list_impl_base *) list)->vtable->size (list);
106  return ((const struct gl_list_impl_base *) list)->vtable
107	 ->search_from_to (list, start_index, size, elt);
108}
109
110gl_list_node_t
111gl_list_search_from_to (gl_list_t list, size_t start_index, size_t end_index, const void *elt)
112{
113  return ((const struct gl_list_impl_base *) list)->vtable
114	 ->search_from_to (list, start_index, end_index, elt);
115}
116
117size_t
118gl_list_indexof (gl_list_t list, const void *elt)
119{
120  size_t size = ((const struct gl_list_impl_base *) list)->vtable->size (list);
121  return ((const struct gl_list_impl_base *) list)->vtable
122	 ->indexof_from_to (list, 0, size, elt);
123}
124
125size_t
126gl_list_indexof_from (gl_list_t list, size_t start_index, const void *elt)
127{
128  size_t size = ((const struct gl_list_impl_base *) list)->vtable->size (list);
129  return ((const struct gl_list_impl_base *) list)->vtable
130	 ->indexof_from_to (list, start_index, size, elt);
131}
132
133size_t
134gl_list_indexof_from_to (gl_list_t list, size_t start_index, size_t end_index, const void *elt)
135{
136  return ((const struct gl_list_impl_base *) list)->vtable
137	 ->indexof_from_to (list, start_index, end_index, elt);
138}
139
140gl_list_node_t
141gl_list_add_first (gl_list_t list, const void *elt)
142{
143  return ((const struct gl_list_impl_base *) list)->vtable
144	 ->add_first (list, elt);
145}
146
147gl_list_node_t
148gl_list_add_last (gl_list_t list, const void *elt)
149{
150  return ((const struct gl_list_impl_base *) list)->vtable
151	 ->add_last (list, elt);
152}
153
154gl_list_node_t
155gl_list_add_before (gl_list_t list, gl_list_node_t node, const void *elt)
156{
157  return ((const struct gl_list_impl_base *) list)->vtable
158	 ->add_before (list, node, elt);
159}
160
161gl_list_node_t
162gl_list_add_after (gl_list_t list, gl_list_node_t node, const void *elt)
163{
164  return ((const struct gl_list_impl_base *) list)->vtable
165	 ->add_after (list, node, elt);
166}
167
168gl_list_node_t
169gl_list_add_at (gl_list_t list, size_t position, const void *elt)
170{
171  return ((const struct gl_list_impl_base *) list)->vtable
172	 ->add_at (list, position, elt);
173}
174
175bool
176gl_list_remove_node (gl_list_t list, gl_list_node_t node)
177{
178  return ((const struct gl_list_impl_base *) list)->vtable
179	 ->remove_node (list, node);
180}
181
182bool
183gl_list_remove_at (gl_list_t list, size_t position)
184{
185  return ((const struct gl_list_impl_base *) list)->vtable
186	 ->remove_at (list, position);
187}
188
189bool
190gl_list_remove (gl_list_t list, const void *elt)
191{
192  return ((const struct gl_list_impl_base *) list)->vtable
193	 ->remove (list, elt);
194}
195
196void
197gl_list_free (gl_list_t list)
198{
199  ((const struct gl_list_impl_base *) list)->vtable->list_free (list);
200}
201
202gl_list_iterator_t
203gl_list_iterator (gl_list_t list)
204{
205  return ((const struct gl_list_impl_base *) list)->vtable
206	 ->iterator (list);
207}
208
209gl_list_iterator_t
210gl_list_iterator_from_to (gl_list_t list, size_t start_index, size_t end_index)
211{
212  return ((const struct gl_list_impl_base *) list)->vtable
213	 ->iterator_from_to (list, start_index, end_index);
214}
215
216bool
217gl_list_iterator_next (gl_list_iterator_t *iterator,
218		       const void **eltp, gl_list_node_t *nodep)
219{
220  return iterator->vtable->iterator_next (iterator, eltp, nodep);
221}
222
223void
224gl_list_iterator_free (gl_list_iterator_t *iterator)
225{
226  iterator->vtable->iterator_free (iterator);
227}
228
229gl_list_node_t
230gl_sortedlist_search (gl_list_t list, gl_listelement_compar_fn compar, const void *elt)
231{
232  return ((const struct gl_list_impl_base *) list)->vtable
233	 ->sortedlist_search (list, compar, elt);
234}
235
236gl_list_node_t
237gl_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{
239  return ((const struct gl_list_impl_base *) list)->vtable
240	 ->sortedlist_search_from_to (list, compar, start_index, end_index,
241				      elt);
242}
243
244size_t
245gl_sortedlist_indexof (gl_list_t list, gl_listelement_compar_fn compar, const void *elt)
246{
247  return ((const struct gl_list_impl_base *) list)->vtable
248	 ->sortedlist_indexof (list, compar, elt);
249}
250
251size_t
252gl_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{
254  return ((const struct gl_list_impl_base *) list)->vtable
255	 ->sortedlist_indexof_from_to (list, compar, start_index, end_index,
256				       elt);
257}
258
259gl_list_node_t
260gl_sortedlist_add (gl_list_t list, gl_listelement_compar_fn compar, const void *elt)
261{
262  return ((const struct gl_list_impl_base *) list)->vtable
263	 ->sortedlist_add (list, compar, elt);
264}
265
266bool
267gl_sortedlist_remove (gl_list_t list, gl_listelement_compar_fn compar, const void *elt)
268{
269  return ((const struct gl_list_impl_base *) list)->vtable
270	 ->sortedlist_remove (list, compar, elt);
271}
272
273#endif
274