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 | #include <config.h>
|
---|
20 |
|
---|
21 | /* Specification. */
|
---|
22 | #include "gl_oset.h"
|
---|
23 |
|
---|
24 | #if !HAVE_INLINE
|
---|
25 |
|
---|
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. */
|
---|
29 |
|
---|
30 | gl_oset_t
|
---|
31 | gl_oset_create_empty (gl_oset_implementation_t implementation,
|
---|
32 | gl_setelement_compar_fn compar_fn)
|
---|
33 | {
|
---|
34 | return implementation->create_empty (implementation, compar_fn);
|
---|
35 | }
|
---|
36 |
|
---|
37 | size_t
|
---|
38 | gl_oset_size (gl_oset_t set)
|
---|
39 | {
|
---|
40 | return ((const struct gl_oset_impl_base *) set)->vtable->size (set);
|
---|
41 | }
|
---|
42 |
|
---|
43 | bool
|
---|
44 | gl_oset_search (gl_oset_t set, const void *elt)
|
---|
45 | {
|
---|
46 | return ((const struct gl_oset_impl_base *) set)->vtable->search (set, elt);
|
---|
47 | }
|
---|
48 |
|
---|
49 | bool
|
---|
50 | gl_oset_search_atleast (gl_oset_t set,
|
---|
51 | gl_setelement_threshold_fn threshold_fn,
|
---|
52 | const void *threshold, const void **eltp)
|
---|
53 | {
|
---|
54 | return ((const struct gl_oset_impl_base *) set)->vtable
|
---|
55 | ->search_atleast (set, threshold_fn, threshold, eltp);
|
---|
56 | }
|
---|
57 |
|
---|
58 | bool
|
---|
59 | gl_oset_add (gl_oset_t set, const void *elt)
|
---|
60 | {
|
---|
61 | return ((const struct gl_oset_impl_base *) set)->vtable->add (set, elt);
|
---|
62 | }
|
---|
63 |
|
---|
64 | bool
|
---|
65 | gl_oset_remove (gl_oset_t set, const void *elt)
|
---|
66 | {
|
---|
67 | return ((const struct gl_oset_impl_base *) set)->vtable->remove (set, elt);
|
---|
68 | }
|
---|
69 |
|
---|
70 | void
|
---|
71 | gl_oset_free (gl_oset_t set)
|
---|
72 | {
|
---|
73 | ((const struct gl_oset_impl_base *) set)->vtable->oset_free (set);
|
---|
74 | }
|
---|
75 |
|
---|
76 | gl_oset_iterator_t
|
---|
77 | gl_oset_iterator (gl_oset_t set)
|
---|
78 | {
|
---|
79 | return ((const struct gl_oset_impl_base *) set)->vtable->iterator (set);
|
---|
80 | }
|
---|
81 |
|
---|
82 | bool
|
---|
83 | gl_oset_iterator_next (gl_oset_iterator_t *iterator, const void **eltp)
|
---|
84 | {
|
---|
85 | return iterator->vtable->iterator_next (iterator, eltp);
|
---|
86 | }
|
---|
87 |
|
---|
88 | void
|
---|
89 | gl_oset_iterator_free (gl_oset_iterator_t *iterator)
|
---|
90 | {
|
---|
91 | iterator->vtable->iterator_free (iterator);
|
---|
92 | }
|
---|
93 |
|
---|
94 | #endif
|
---|