40e507342e54b0c3098109a5d02691911f7c0c7c
[platform/upstream/m4.git] / lib / gl_oset.c
1 /* Abstract ordered set data type.
2    Copyright (C) 2006-2007, 2009-2011 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_oset.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
29 gl_oset_t
30 gl_oset_nx_create_empty (gl_oset_implementation_t implementation,
31                          gl_setelement_compar_fn compar_fn,
32                          gl_setelement_dispose_fn dispose_fn)
33 {
34   return implementation->nx_create_empty (implementation, compar_fn,
35                                           dispose_fn);
36 }
37
38 size_t
39 gl_oset_size (gl_oset_t set)
40 {
41   return ((const struct gl_oset_impl_base *) set)->vtable->size (set);
42 }
43
44 bool
45 gl_oset_search (gl_oset_t set, const void *elt)
46 {
47   return ((const struct gl_oset_impl_base *) set)->vtable->search (set, elt);
48 }
49
50 bool
51 gl_oset_search_atleast (gl_oset_t set,
52                         gl_setelement_threshold_fn threshold_fn,
53                         const void *threshold, const void **eltp)
54 {
55   return ((const struct gl_oset_impl_base *) set)->vtable
56          ->search_atleast (set, threshold_fn, threshold, eltp);
57 }
58
59 int
60 gl_oset_nx_add (gl_oset_t set, const void *elt)
61 {
62   return ((const struct gl_oset_impl_base *) set)->vtable->nx_add (set, elt);
63 }
64
65 bool
66 gl_oset_remove (gl_oset_t set, const void *elt)
67 {
68   return ((const struct gl_oset_impl_base *) set)->vtable
69          ->remove_elt (set, elt);
70 }
71
72 void
73 gl_oset_free (gl_oset_t set)
74 {
75   ((const struct gl_oset_impl_base *) set)->vtable->oset_free (set);
76 }
77
78 gl_oset_iterator_t
79 gl_oset_iterator (gl_oset_t set)
80 {
81   return ((const struct gl_oset_impl_base *) set)->vtable->iterator (set);
82 }
83
84 bool
85 gl_oset_iterator_next (gl_oset_iterator_t *iterator, const void **eltp)
86 {
87   return iterator->vtable->iterator_next (iterator, eltp);
88 }
89
90 void
91 gl_oset_iterator_free (gl_oset_iterator_t *iterator)
92 {
93   iterator->vtable->iterator_free (iterator);
94 }
95
96 #endif