Abstract ordered set data type.
[gnulib.git] / lib / gl_oset.c
1 /* Abstract ordered set data type.
2    Copyright (C) 2006 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 2, or (at your option)
8    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, write to the Free Software Foundation,
17    Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */
18
19 #ifdef HAVE_CONFIG_H
20 # include <config.h>
21 #endif
22
23 /* Specification.  */
24 #include "gl_oset.h"
25
26 #if !HAVE_INLINE
27
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.  */
31
32 gl_oset_t
33 gl_oset_create_empty (gl_oset_implementation_t implementation,
34                       gl_setelement_compar_fn compar_fn)
35 {
36   return implementation->create_empty (implementation, compar_fn);
37 }
38
39 size_t
40 gl_oset_size (gl_oset_t set)
41 {
42   return ((const struct gl_oset_impl_base *) set)->vtable->size (set);
43 }
44
45 bool
46 gl_oset_search (gl_oset_t set, const void *elt)
47 {
48   return ((const struct gl_oset_impl_base *) set)->vtable->search (set, elt);
49 }
50
51 void
52 gl_oset_add (gl_oset_t set, const void *elt)
53 {
54   return ((const struct gl_oset_impl_base *) set)->vtable->add (set, elt);
55 }
56
57 bool
58 gl_oset_remove (gl_oset_t set, const void *elt)
59 {
60   return ((const struct gl_oset_impl_base *) set)->vtable->remove (set, elt);
61 }
62
63 void
64 gl_oset_free (gl_oset_t set)
65 {
66   ((const struct gl_oset_impl_base *) set)->vtable->oset_free (set);
67 }
68
69 gl_oset_iterator_t
70 gl_oset_iterator (gl_oset_t set)
71 {
72   return ((const struct gl_oset_impl_base *) set)->vtable->iterator (set);
73 }
74
75 bool
76 gl_oset_iterator_next (gl_oset_iterator_t *iterator, const void **eltp)
77 {
78   return iterator->vtable->iterator_next (iterator, eltp);
79 }
80
81 void
82 gl_oset_iterator_free (gl_oset_iterator_t *iterator)
83 {
84   iterator->vtable->iterator_free (iterator);
85 }
86
87 #endif