1 /* sortedset.c generated by valac 0.19.0.4-d6d4, the Vala compiler
2 * generated from sortedset.vala, do not modify */
3
4 /* sortedset.vala
5 *
6 * Copyright (C) 2009 Didier Villevalois, Maciej Piechotka
7 *
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
12
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
17
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 *
22 * Author:
23 * Maciej Piechotka <uzytkownik2@gmail.com>
24 */
25
26 #include <glib.h>
27 #include <glib-object.h>
28
29
30 #define GEE_TYPE_ITERABLE (gee_iterable_get_type ())
31 #define GEE_ITERABLE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GEE_TYPE_ITERABLE, GeeIterable))
32 #define GEE_IS_ITERABLE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GEE_TYPE_ITERABLE))
33 #define GEE_ITERABLE_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), GEE_TYPE_ITERABLE, GeeIterableIface))
34
35 typedef struct _GeeIterable GeeIterable;
36 typedef struct _GeeIterableIface GeeIterableIface;
37
38 #define GEE_TYPE_ITERATOR (gee_iterator_get_type ())
39 #define GEE_ITERATOR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GEE_TYPE_ITERATOR, GeeIterator))
40 #define GEE_IS_ITERATOR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GEE_TYPE_ITERATOR))
41 #define GEE_ITERATOR_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), GEE_TYPE_ITERATOR, GeeIteratorIface))
42
43 typedef struct _GeeIterator GeeIterator;
44 typedef struct _GeeIteratorIface GeeIteratorIface;
45
46 #define GEE_TYPE_COLLECTION (gee_collection_get_type ())
47 #define GEE_COLLECTION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GEE_TYPE_COLLECTION, GeeCollection))
48 #define GEE_IS_COLLECTION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GEE_TYPE_COLLECTION))
49 #define GEE_COLLECTION_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), GEE_TYPE_COLLECTION, GeeCollectionIface))
50
51 typedef struct _GeeCollection GeeCollection;
52 typedef struct _GeeCollectionIface GeeCollectionIface;
53
54 #define GEE_TYPE_SET (gee_set_get_type ())
55 #define GEE_SET(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GEE_TYPE_SET, GeeSet))
56 #define GEE_IS_SET(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GEE_TYPE_SET))
57 #define GEE_SET_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), GEE_TYPE_SET, GeeSetIface))
58
59 typedef struct _GeeSet GeeSet;
60 typedef struct _GeeSetIface GeeSetIface;
61
62 #define GEE_TYPE_SORTED_SET (gee_sorted_set_get_type ())
63 #define GEE_SORTED_SET(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GEE_TYPE_SORTED_SET, GeeSortedSet))
64 #define GEE_IS_SORTED_SET(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GEE_TYPE_SORTED_SET))
65 #define GEE_SORTED_SET_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), GEE_TYPE_SORTED_SET, GeeSortedSetIface))
66
67 typedef struct _GeeSortedSet GeeSortedSet;
68 typedef struct _GeeSortedSetIface GeeSortedSetIface;
69
70 #define GEE_TYPE_BIDIR_ITERATOR (gee_bidir_iterator_get_type ())
71 #define GEE_BIDIR_ITERATOR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GEE_TYPE_BIDIR_ITERATOR, GeeBidirIterator))
72 #define GEE_IS_BIDIR_ITERATOR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GEE_TYPE_BIDIR_ITERATOR))
73 #define GEE_BIDIR_ITERATOR_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), GEE_TYPE_BIDIR_ITERATOR, GeeBidirIteratorIface))
74
75 typedef struct _GeeBidirIterator GeeBidirIterator;
76 typedef struct _GeeBidirIteratorIface GeeBidirIteratorIface;
77
78 struct _GeeIteratorIface {
79 GTypeInterface parent_iface;
80 gboolean (*next) (GeeIterator* self);
81 gboolean (*has_next) (GeeIterator* self);
82 gboolean (*first) (GeeIterator* self);
83 gpointer (*get) (GeeIterator* self);
84 void (*remove) (GeeIterator* self);
85 };
86
87 struct _GeeIterableIface {
88 GTypeInterface parent_iface;
89 GeeIterator* (*iterator) (GeeIterable* self);
90 GType (*get_element_type) (GeeIterable* self);
91 };
92
93 struct _GeeCollectionIface {
94 GTypeInterface parent_iface;
95 gboolean (*contains) (GeeCollection* self, gconstpointer item);
96 gboolean (*add) (GeeCollection* self, gconstpointer item);
97 gboolean (*remove) (GeeCollection* self, gconstpointer item);
98 void (*clear) (GeeCollection* self);
99 gboolean (*add_all) (GeeCollection* self, GeeCollection* collection);
100 gboolean (*contains_all) (GeeCollection* self, GeeCollection* collection);
101 gboolean (*remove_all) (GeeCollection* self, GeeCollection* collection);
102 gboolean (*retain_all) (GeeCollection* self, GeeCollection* collection);
103 gpointer* (*to_array) (GeeCollection* self, int* result_length1);
104 gint (*get_size) (GeeCollection* self);
105 gboolean (*get_is_empty) (GeeCollection* self);
106 GeeCollection* (*get_read_only_view) (GeeCollection* self);
107 };
108
109 struct _GeeSetIface {
110 GTypeInterface parent_iface;
111 GeeSet* (*get_read_only_view) (GeeSet* self);
112 };
113
114 struct _GeeBidirIteratorIface {
115 GTypeInterface parent_iface;
116 gboolean (*previous) (GeeBidirIterator* self);
117 gboolean (*has_previous) (GeeBidirIterator* self);
118 gboolean (*last) (GeeBidirIterator* self);
119 };
120
121 struct _GeeSortedSetIface {
122 GTypeInterface parent_iface;
123 gpointer (*first) (GeeSortedSet* self);
124 gpointer (*last) (GeeSortedSet* self);
125 GeeBidirIterator* (*bidir_iterator) (GeeSortedSet* self);
126 GeeBidirIterator* (*iterator_at) (GeeSortedSet* self, gconstpointer element);
127 gpointer (*lower) (GeeSortedSet* self, gconstpointer element);
128 gpointer (*higher) (GeeSortedSet* self, gconstpointer element);
129 gpointer (*floor) (GeeSortedSet* self, gconstpointer element);
130 gpointer (*ceil) (GeeSortedSet* self, gconstpointer element);
131 GeeSortedSet* (*head_set) (GeeSortedSet* self, gconstpointer before);
132 GeeSortedSet* (*tail_set) (GeeSortedSet* self, gconstpointer after);
133 GeeSortedSet* (*sub_set) (GeeSortedSet* self, gconstpointer from, gconstpointer to);
134 };
135
136
137
138 GType gee_iterator_get_type (void) G_GNUC_CONST;
139 GType gee_iterable_get_type (void) G_GNUC_CONST;
140 GType gee_collection_get_type (void) G_GNUC_CONST;
141 GType gee_set_get_type (void) G_GNUC_CONST;
142 GType gee_bidir_iterator_get_type (void) G_GNUC_CONST;
143 GType gee_sorted_set_get_type (void) G_GNUC_CONST;
144 gpointer gee_sorted_set_first (GeeSortedSet* self);
145 gpointer gee_sorted_set_last (GeeSortedSet* self);
146 GeeBidirIterator* gee_sorted_set_bidir_iterator (GeeSortedSet* self);
147 GeeBidirIterator* gee_sorted_set_iterator_at (GeeSortedSet* self, gconstpointer element);
148 gpointer gee_sorted_set_lower (GeeSortedSet* self, gconstpointer element);
149 gpointer gee_sorted_set_higher (GeeSortedSet* self, gconstpointer element);
150 gpointer gee_sorted_set_floor (GeeSortedSet* self, gconstpointer element);
151 gpointer gee_sorted_set_ceil (GeeSortedSet* self, gconstpointer element);
152 GeeSortedSet* gee_sorted_set_head_set (GeeSortedSet* self, gconstpointer before);
153 GeeSortedSet* gee_sorted_set_tail_set (GeeSortedSet* self, gconstpointer after);
154 GeeSortedSet* gee_sorted_set_sub_set (GeeSortedSet* self, gconstpointer from, gconstpointer to);
155
156
157 /**
158 * Returns the first element of the sorted set. Set must not be empty.
159 *
160 * @return the first element in the sorted set
161 */
gee_sorted_set_first(GeeSortedSet * self)162 gpointer gee_sorted_set_first (GeeSortedSet* self) {
163 g_return_val_if_fail (self != NULL, NULL);
164 return GEE_SORTED_SET_GET_INTERFACE (self)->first (self);
165 }
166
167
168 /**
169 * Returns the last element of the sorted set. Set must not be empty.
170 *
171 * @return the last element in the sorted set
172 */
gee_sorted_set_last(GeeSortedSet * self)173 gpointer gee_sorted_set_last (GeeSortedSet* self) {
174 g_return_val_if_fail (self != NULL, NULL);
175 return GEE_SORTED_SET_GET_INTERFACE (self)->last (self);
176 }
177
178
179 /**
180 * Returns a {@link BidirIterator} that can be used for bi-directional
181 * iteration over this sorted set.
182 *
183 * @return a {@link BidirIterator} over this sorted set
184 */
gee_sorted_set_bidir_iterator(GeeSortedSet * self)185 GeeBidirIterator* gee_sorted_set_bidir_iterator (GeeSortedSet* self) {
186 g_return_val_if_fail (self != NULL, NULL);
187 return GEE_SORTED_SET_GET_INTERFACE (self)->bidir_iterator (self);
188 }
189
190
191 /**
192 * Returns a {@link BidirIterator} initialy pointed at the specified
193 * element.
194 *
195 * @param element the element to point the iterator at
196 *
197 * @return a {@link BidirIterator} over this sorted set, or null if
198 * the specified element is not in this set
199 */
gee_sorted_set_iterator_at(GeeSortedSet * self,gconstpointer element)200 GeeBidirIterator* gee_sorted_set_iterator_at (GeeSortedSet* self, gconstpointer element) {
201 g_return_val_if_fail (self != NULL, NULL);
202 return GEE_SORTED_SET_GET_INTERFACE (self)->iterator_at (self, element);
203 }
204
205
206 /**
207 * Returns the element which is strictly lower than the specified element.
208 *
209 * @param element the element which you want the lower element for
210 *
211 * @return the corresponding element
212 */
gee_sorted_set_lower(GeeSortedSet * self,gconstpointer element)213 gpointer gee_sorted_set_lower (GeeSortedSet* self, gconstpointer element) {
214 g_return_val_if_fail (self != NULL, NULL);
215 return GEE_SORTED_SET_GET_INTERFACE (self)->lower (self, element);
216 }
217
218
219 /**
220 * Returns the element which is strictly higher than the specified element.
221 *
222 * @param element the element which you want the strictly higher element
223 * for
224 *
225 * @return the corresponding element
226 */
gee_sorted_set_higher(GeeSortedSet * self,gconstpointer element)227 gpointer gee_sorted_set_higher (GeeSortedSet* self, gconstpointer element) {
228 g_return_val_if_fail (self != NULL, NULL);
229 return GEE_SORTED_SET_GET_INTERFACE (self)->higher (self, element);
230 }
231
232
233 /**
234 * Returns the element which is lower or equal then the specified element.
235 *
236 * @param element the element which you want the lower or equal element for
237 *
238 * @return the corresponding element
239 */
gee_sorted_set_floor(GeeSortedSet * self,gconstpointer element)240 gpointer gee_sorted_set_floor (GeeSortedSet* self, gconstpointer element) {
241 g_return_val_if_fail (self != NULL, NULL);
242 return GEE_SORTED_SET_GET_INTERFACE (self)->floor (self, element);
243 }
244
245
246 /**
247 * Returns the element which is higher or equal then the specified element.
248 *
249 * @param element the element which you want the higher or equal element
250 * for
251 *
252 * @return the corresponding element
253 */
gee_sorted_set_ceil(GeeSortedSet * self,gconstpointer element)254 gpointer gee_sorted_set_ceil (GeeSortedSet* self, gconstpointer element) {
255 g_return_val_if_fail (self != NULL, NULL);
256 return GEE_SORTED_SET_GET_INTERFACE (self)->ceil (self, element);
257 }
258
259
260 /**
261 * Returns the sub-set of this sorted set containing elements strictly
262 * lower than the specified element.
263 *
264 * @param before the lower inclusive bound for the sub-set
265 *
266 * @return the corresponding sub-set of this sorted set
267 */
gee_sorted_set_head_set(GeeSortedSet * self,gconstpointer before)268 GeeSortedSet* gee_sorted_set_head_set (GeeSortedSet* self, gconstpointer before) {
269 g_return_val_if_fail (self != NULL, NULL);
270 return GEE_SORTED_SET_GET_INTERFACE (self)->head_set (self, before);
271 }
272
273
274 /**
275 * Returns the sub-set of this sorted set containing elements equal or
276 * higher than the specified element.
277 *
278 * @param after the higher exclusive bound for the sub-set
279 *
280 * @return the corresponding sub-set of this sorted set
281 */
gee_sorted_set_tail_set(GeeSortedSet * self,gconstpointer after)282 GeeSortedSet* gee_sorted_set_tail_set (GeeSortedSet* self, gconstpointer after) {
283 g_return_val_if_fail (self != NULL, NULL);
284 return GEE_SORTED_SET_GET_INTERFACE (self)->tail_set (self, after);
285 }
286
287
288 /**
289 * Returns the right-open sub-set of this sorted set, thus containing
290 * elements equal or higher than the specified ``from`` element, and stricly
291 * lower than the specified ``to`` element.
292 *
293 * @param from the lower inclusive bound for the sub-set
294 * @param to the higher exclusive bound for the sub-set
295 *
296 * @return the corresponding sub-set of this sorted set
297 */
gee_sorted_set_sub_set(GeeSortedSet * self,gconstpointer from,gconstpointer to)298 GeeSortedSet* gee_sorted_set_sub_set (GeeSortedSet* self, gconstpointer from, gconstpointer to) {
299 g_return_val_if_fail (self != NULL, NULL);
300 return GEE_SORTED_SET_GET_INTERFACE (self)->sub_set (self, from, to);
301 }
302
303
gee_sorted_set_base_init(GeeSortedSetIface * iface)304 static void gee_sorted_set_base_init (GeeSortedSetIface * iface) {
305 static gboolean initialized = FALSE;
306 if (!initialized) {
307 initialized = TRUE;
308 }
309 }
310
311
312 /**
313 * A sorted set, which you can navigate over and get sub-sets of.
314 */
gee_sorted_set_get_type(void)315 GType gee_sorted_set_get_type (void) {
316 static volatile gsize gee_sorted_set_type_id__volatile = 0;
317 if (g_once_init_enter (&gee_sorted_set_type_id__volatile)) {
318 static const GTypeInfo g_define_type_info = { sizeof (GeeSortedSetIface), (GBaseInitFunc) gee_sorted_set_base_init, (GBaseFinalizeFunc) NULL, (GClassInitFunc) NULL, (GClassFinalizeFunc) NULL, NULL, 0, 0, (GInstanceInitFunc) NULL, NULL };
319 GType gee_sorted_set_type_id;
320 gee_sorted_set_type_id = g_type_register_static (G_TYPE_INTERFACE, "GeeSortedSet", &g_define_type_info, 0);
321 g_type_interface_add_prerequisite (gee_sorted_set_type_id, GEE_TYPE_SET);
322 g_once_init_leave (&gee_sorted_set_type_id__volatile, gee_sorted_set_type_id);
323 }
324 return gee_sorted_set_type_id__volatile;
325 }
326
327
328
329