49b431d2ae74640186fc2602c01dc575ea05f9f6
[profile/ivi/libgee.git] / gee / hashset.c
1 /* hashset.c generated by valac 0.18.0, the Vala compiler
2  * generated from hashset.vala, do not modify */
3
4 /* hashset.vala
5  *
6  * Copyright (C) 1995-1997  Peter Mattis, Spencer Kimball and Josh MacDonald
7  * Copyright (C) 1997-2000  GLib Team and others
8  * Copyright (C) 2007-2009  Jürg Billeter
9  *
10  * This library is free software; you can redistribute it and/or
11  * modify it under the terms of the GNU Lesser General Public
12  * License as published by the Free Software Foundation; either
13  * version 2.1 of the License, or (at your option) any later version.
14
15  * This library is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
18  * Lesser General Public License for more details.
19
20  * You should have received a copy of the GNU Lesser General Public
21  * License along with this library; if not, write to the Free Software
22  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
23  *
24  * Author:
25  *      Jürg Billeter <j@bitron.ch>
26  */
27
28 #include <glib.h>
29 #include <glib-object.h>
30
31
32 #define GEE_TYPE_ITERABLE (gee_iterable_get_type ())
33 #define GEE_ITERABLE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GEE_TYPE_ITERABLE, GeeIterable))
34 #define GEE_IS_ITERABLE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GEE_TYPE_ITERABLE))
35 #define GEE_ITERABLE_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), GEE_TYPE_ITERABLE, GeeIterableIface))
36
37 typedef struct _GeeIterable GeeIterable;
38 typedef struct _GeeIterableIface GeeIterableIface;
39
40 #define GEE_TYPE_ITERATOR (gee_iterator_get_type ())
41 #define GEE_ITERATOR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GEE_TYPE_ITERATOR, GeeIterator))
42 #define GEE_IS_ITERATOR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GEE_TYPE_ITERATOR))
43 #define GEE_ITERATOR_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), GEE_TYPE_ITERATOR, GeeIteratorIface))
44
45 typedef struct _GeeIterator GeeIterator;
46 typedef struct _GeeIteratorIface GeeIteratorIface;
47
48 #define GEE_TYPE_COLLECTION (gee_collection_get_type ())
49 #define GEE_COLLECTION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GEE_TYPE_COLLECTION, GeeCollection))
50 #define GEE_IS_COLLECTION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GEE_TYPE_COLLECTION))
51 #define GEE_COLLECTION_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), GEE_TYPE_COLLECTION, GeeCollectionIface))
52
53 typedef struct _GeeCollection GeeCollection;
54 typedef struct _GeeCollectionIface GeeCollectionIface;
55
56 #define GEE_TYPE_ABSTRACT_COLLECTION (gee_abstract_collection_get_type ())
57 #define GEE_ABSTRACT_COLLECTION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GEE_TYPE_ABSTRACT_COLLECTION, GeeAbstractCollection))
58 #define GEE_ABSTRACT_COLLECTION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GEE_TYPE_ABSTRACT_COLLECTION, GeeAbstractCollectionClass))
59 #define GEE_IS_ABSTRACT_COLLECTION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GEE_TYPE_ABSTRACT_COLLECTION))
60 #define GEE_IS_ABSTRACT_COLLECTION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GEE_TYPE_ABSTRACT_COLLECTION))
61 #define GEE_ABSTRACT_COLLECTION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GEE_TYPE_ABSTRACT_COLLECTION, GeeAbstractCollectionClass))
62
63 typedef struct _GeeAbstractCollection GeeAbstractCollection;
64 typedef struct _GeeAbstractCollectionClass GeeAbstractCollectionClass;
65 typedef struct _GeeAbstractCollectionPrivate GeeAbstractCollectionPrivate;
66
67 #define GEE_TYPE_SET (gee_set_get_type ())
68 #define GEE_SET(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GEE_TYPE_SET, GeeSet))
69 #define GEE_IS_SET(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GEE_TYPE_SET))
70 #define GEE_SET_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), GEE_TYPE_SET, GeeSetIface))
71
72 typedef struct _GeeSet GeeSet;
73 typedef struct _GeeSetIface GeeSetIface;
74
75 #define GEE_TYPE_ABSTRACT_SET (gee_abstract_set_get_type ())
76 #define GEE_ABSTRACT_SET(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GEE_TYPE_ABSTRACT_SET, GeeAbstractSet))
77 #define GEE_ABSTRACT_SET_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GEE_TYPE_ABSTRACT_SET, GeeAbstractSetClass))
78 #define GEE_IS_ABSTRACT_SET(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GEE_TYPE_ABSTRACT_SET))
79 #define GEE_IS_ABSTRACT_SET_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GEE_TYPE_ABSTRACT_SET))
80 #define GEE_ABSTRACT_SET_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GEE_TYPE_ABSTRACT_SET, GeeAbstractSetClass))
81
82 typedef struct _GeeAbstractSet GeeAbstractSet;
83 typedef struct _GeeAbstractSetClass GeeAbstractSetClass;
84 typedef struct _GeeAbstractSetPrivate GeeAbstractSetPrivate;
85
86 #define GEE_TYPE_HASH_SET (gee_hash_set_get_type ())
87 #define GEE_HASH_SET(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GEE_TYPE_HASH_SET, GeeHashSet))
88 #define GEE_HASH_SET_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GEE_TYPE_HASH_SET, GeeHashSetClass))
89 #define GEE_IS_HASH_SET(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GEE_TYPE_HASH_SET))
90 #define GEE_IS_HASH_SET_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GEE_TYPE_HASH_SET))
91 #define GEE_HASH_SET_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GEE_TYPE_HASH_SET, GeeHashSetClass))
92
93 typedef struct _GeeHashSet GeeHashSet;
94 typedef struct _GeeHashSetClass GeeHashSetClass;
95 typedef struct _GeeHashSetPrivate GeeHashSetPrivate;
96 typedef struct _GeeHashSetNode GeeHashSetNode;
97
98 #define GEE_HASH_SET_TYPE_ITERATOR (gee_hash_set_iterator_get_type ())
99 #define GEE_HASH_SET_ITERATOR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GEE_HASH_SET_TYPE_ITERATOR, GeeHashSetIterator))
100 #define GEE_HASH_SET_ITERATOR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GEE_HASH_SET_TYPE_ITERATOR, GeeHashSetIteratorClass))
101 #define GEE_HASH_SET_IS_ITERATOR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GEE_HASH_SET_TYPE_ITERATOR))
102 #define GEE_HASH_SET_IS_ITERATOR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GEE_HASH_SET_TYPE_ITERATOR))
103 #define GEE_HASH_SET_ITERATOR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GEE_HASH_SET_TYPE_ITERATOR, GeeHashSetIteratorClass))
104
105 typedef struct _GeeHashSetIterator GeeHashSetIterator;
106 typedef struct _GeeHashSetIteratorClass GeeHashSetIteratorClass;
107 #define _gee_hash_set_node_free0(var) ((var == NULL) ? NULL : (var = (gee_hash_set_node_free (var), NULL)))
108 typedef struct _GeeHashSetIteratorPrivate GeeHashSetIteratorPrivate;
109 #define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
110 #define _vala_assert(expr, msg) if G_LIKELY (expr) ; else g_assertion_message_expr (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, msg);
111
112 struct _GeeIteratorIface {
113         GTypeInterface parent_iface;
114         gboolean (*next) (GeeIterator* self);
115         gboolean (*has_next) (GeeIterator* self);
116         gboolean (*first) (GeeIterator* self);
117         gpointer (*get) (GeeIterator* self);
118         void (*remove) (GeeIterator* self);
119 };
120
121 struct _GeeIterableIface {
122         GTypeInterface parent_iface;
123         GeeIterator* (*iterator) (GeeIterable* self);
124         GType (*get_element_type) (GeeIterable* self);
125 };
126
127 struct _GeeCollectionIface {
128         GTypeInterface parent_iface;
129         gboolean (*contains) (GeeCollection* self, gconstpointer item);
130         gboolean (*add) (GeeCollection* self, gconstpointer item);
131         gboolean (*remove) (GeeCollection* self, gconstpointer item);
132         void (*clear) (GeeCollection* self);
133         gboolean (*add_all) (GeeCollection* self, GeeCollection* collection);
134         gboolean (*contains_all) (GeeCollection* self, GeeCollection* collection);
135         gboolean (*remove_all) (GeeCollection* self, GeeCollection* collection);
136         gboolean (*retain_all) (GeeCollection* self, GeeCollection* collection);
137         gpointer* (*to_array) (GeeCollection* self, int* result_length1);
138         gint (*get_size) (GeeCollection* self);
139         gboolean (*get_is_empty) (GeeCollection* self);
140         GeeCollection* (*get_read_only_view) (GeeCollection* self);
141 };
142
143 struct _GeeAbstractCollection {
144         GObject parent_instance;
145         GeeAbstractCollectionPrivate * priv;
146 };
147
148 struct _GeeAbstractCollectionClass {
149         GObjectClass parent_class;
150         gboolean (*contains) (GeeAbstractCollection* self, gconstpointer item);
151         gboolean (*add) (GeeAbstractCollection* self, gconstpointer item);
152         gboolean (*remove) (GeeAbstractCollection* self, gconstpointer item);
153         void (*clear) (GeeAbstractCollection* self);
154         gpointer* (*to_array) (GeeAbstractCollection* self, int* result_length1);
155         gboolean (*add_all) (GeeAbstractCollection* self, GeeCollection* collection);
156         gboolean (*contains_all) (GeeAbstractCollection* self, GeeCollection* collection);
157         gboolean (*remove_all) (GeeAbstractCollection* self, GeeCollection* collection);
158         gboolean (*retain_all) (GeeAbstractCollection* self, GeeCollection* collection);
159         GeeIterator* (*iterator) (GeeAbstractCollection* self);
160         gint (*get_size) (GeeAbstractCollection* self);
161         gboolean (*get_is_empty) (GeeAbstractCollection* self);
162         GeeCollection* (*get_read_only_view) (GeeAbstractCollection* self);
163 };
164
165 struct _GeeSetIface {
166         GTypeInterface parent_iface;
167         GeeSet* (*get_read_only_view) (GeeSet* self);
168 };
169
170 struct _GeeAbstractSet {
171         GeeAbstractCollection parent_instance;
172         GeeAbstractSetPrivate * priv;
173 };
174
175 struct _GeeAbstractSetClass {
176         GeeAbstractCollectionClass parent_class;
177         GeeSet* (*get_read_only_view) (GeeAbstractSet* self);
178 };
179
180 struct _GeeHashSet {
181         GeeAbstractSet parent_instance;
182         GeeHashSetPrivate * priv;
183 };
184
185 struct _GeeHashSetClass {
186         GeeAbstractSetClass parent_class;
187 };
188
189 struct _GeeHashSetPrivate {
190         GType g_type;
191         GBoxedCopyFunc g_dup_func;
192         GDestroyNotify g_destroy_func;
193         GHashFunc _hash_func;
194         GEqualFunc _equal_func;
195         gint _array_size;
196         gint _nnodes;
197         GeeHashSetNode** _nodes;
198         gint _nodes_length1;
199         gint __nodes_size_;
200         gint _stamp;
201 };
202
203 struct _GeeHashSetNode {
204         gpointer key;
205         GeeHashSetNode* next;
206         guint key_hash;
207 };
208
209 struct _GeeHashSetIterator {
210         GObject parent_instance;
211         GeeHashSetIteratorPrivate * priv;
212 };
213
214 struct _GeeHashSetIteratorClass {
215         GObjectClass parent_class;
216 };
217
218 struct _GeeHashSetIteratorPrivate {
219         GType g_type;
220         GBoxedCopyFunc g_dup_func;
221         GDestroyNotify g_destroy_func;
222         GeeHashSet* _set;
223         gint _index;
224         GeeHashSetNode* _node;
225         GeeHashSetNode* _next;
226         gint _stamp;
227 };
228
229
230 static gpointer gee_hash_set_parent_class = NULL;
231 static gpointer gee_hash_set_iterator_parent_class = NULL;
232 static GeeIteratorIface* gee_hash_set_iterator_gee_iterator_parent_iface = NULL;
233
234 GType gee_iterator_get_type (void) G_GNUC_CONST;
235 GType gee_iterable_get_type (void) G_GNUC_CONST;
236 GType gee_collection_get_type (void) G_GNUC_CONST;
237 GType gee_abstract_collection_get_type (void) G_GNUC_CONST;
238 GType gee_set_get_type (void) G_GNUC_CONST;
239 GType gee_abstract_set_get_type (void) G_GNUC_CONST;
240 GType gee_hash_set_get_type (void) G_GNUC_CONST;
241 static void gee_hash_set_node_free (GeeHashSetNode* self);
242 #define GEE_HASH_SET_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GEE_TYPE_HASH_SET, GeeHashSetPrivate))
243 enum  {
244         GEE_HASH_SET_DUMMY_PROPERTY,
245         GEE_HASH_SET_G_TYPE,
246         GEE_HASH_SET_G_DUP_FUNC,
247         GEE_HASH_SET_G_DESTROY_FUNC,
248         GEE_HASH_SET_SIZE,
249         GEE_HASH_SET_HASH_FUNC,
250         GEE_HASH_SET_EQUAL_FUNC
251 };
252 void gee_abstract_collection_clear (GeeAbstractCollection* self);
253 #define GEE_HASH_SET_MIN_SIZE 11
254 #define GEE_HASH_SET_MAX_SIZE 13845163
255 GeeHashSet* gee_hash_set_new (GType g_type, GBoxedCopyFunc g_dup_func, GDestroyNotify g_destroy_func, GHashFunc hash_func, GEqualFunc equal_func);
256 GeeHashSet* gee_hash_set_construct (GType object_type, GType g_type, GBoxedCopyFunc g_dup_func, GDestroyNotify g_destroy_func, GHashFunc hash_func, GEqualFunc equal_func);
257 GeeAbstractSet* gee_abstract_set_construct (GType object_type, GType g_type, GBoxedCopyFunc g_dup_func, GDestroyNotify g_destroy_func);
258 GHashFunc gee_functions_get_hash_func_for (GType t);
259 GEqualFunc gee_functions_get_equal_func_for (GType t);
260 static void gee_hash_set_set_hash_func (GeeHashSet* self, GHashFunc value);
261 static void gee_hash_set_set_equal_func (GeeHashSet* self, GEqualFunc value);
262 static GeeHashSetNode** gee_hash_set_lookup_node (GeeHashSet* self, gconstpointer key);
263 GHashFunc gee_hash_set_get_hash_func (GeeHashSet* self);
264 GEqualFunc gee_hash_set_get_equal_func (GeeHashSet* self);
265 static gboolean gee_hash_set_real_contains (GeeAbstractCollection* base, gconstpointer key);
266 static GeeIterator* gee_hash_set_real_iterator (GeeAbstractCollection* base);
267 static GeeHashSetIterator* gee_hash_set_iterator_new (GType g_type, GBoxedCopyFunc g_dup_func, GDestroyNotify g_destroy_func, GeeHashSet* set);
268 static GeeHashSetIterator* gee_hash_set_iterator_construct (GType object_type, GType g_type, GBoxedCopyFunc g_dup_func, GDestroyNotify g_destroy_func, GeeHashSet* set);
269 static GType gee_hash_set_iterator_get_type (void) G_GNUC_CONST G_GNUC_UNUSED;
270 static gboolean gee_hash_set_real_add (GeeAbstractCollection* base, gconstpointer key);
271 static GeeHashSetNode* gee_hash_set_node_new (gpointer k, guint hash);
272 static GeeHashSetNode* gee_hash_set_node_new (gpointer k, guint hash);
273 static void gee_hash_set_resize (GeeHashSet* self);
274 static gboolean gee_hash_set_real_remove (GeeAbstractCollection* base, gconstpointer key);
275 static inline gboolean gee_hash_set_remove_helper (GeeHashSet* self, gconstpointer key);
276 static void gee_hash_set_real_clear (GeeAbstractCollection* base);
277 static void gee_hash_set_node_instance_init (GeeHashSetNode * self);
278 #define GEE_HASH_SET_ITERATOR_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GEE_HASH_SET_TYPE_ITERATOR, GeeHashSetIteratorPrivate))
279 enum  {
280         GEE_HASH_SET_ITERATOR_DUMMY_PROPERTY,
281         GEE_HASH_SET_ITERATOR_G_TYPE,
282         GEE_HASH_SET_ITERATOR_G_DUP_FUNC,
283         GEE_HASH_SET_ITERATOR_G_DESTROY_FUNC
284 };
285 static gboolean gee_hash_set_iterator_real_next (GeeIterator* base);
286 gboolean gee_iterator_has_next (GeeIterator* self);
287 static gboolean gee_hash_set_iterator_real_has_next (GeeIterator* base);
288 static gboolean gee_hash_set_iterator_real_first (GeeIterator* base);
289 gint gee_abstract_collection_get_size (GeeAbstractCollection* self);
290 gboolean gee_iterator_next (GeeIterator* self);
291 static gpointer gee_hash_set_iterator_real_get (GeeIterator* base);
292 static void gee_hash_set_iterator_real_remove (GeeIterator* base);
293 static void gee_hash_set_iterator_finalize (GObject* obj);
294 static void _vala_gee_hash_set_iterator_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec);
295 static void _vala_gee_hash_set_iterator_set_property (GObject * object, guint property_id, const GValue * value, GParamSpec * pspec);
296 static void gee_hash_set_finalize (GObject* obj);
297 static void _vala_gee_hash_set_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec);
298 static void _vala_gee_hash_set_set_property (GObject * object, guint property_id, const GValue * value, GParamSpec * pspec);
299 static void _vala_array_destroy (gpointer array, gint array_length, GDestroyNotify destroy_func);
300 static void _vala_array_free (gpointer array, gint array_length, GDestroyNotify destroy_func);
301
302
303 /**
304  * Constructs a new, empty hash set.
305  *
306  * If not provided, the functions parameters are requested to the
307  * {@link Functions} function factory methods.
308  *
309  * @param hash_func an optional hash function
310  * @param equal_func an optional equality testing function
311  */
312 GeeHashSet* gee_hash_set_construct (GType object_type, GType g_type, GBoxedCopyFunc g_dup_func, GDestroyNotify g_destroy_func, GHashFunc hash_func, GEqualFunc equal_func) {
313         GeeHashSet * self = NULL;
314         GHashFunc _tmp0_;
315         GEqualFunc _tmp2_;
316         GHashFunc _tmp4_;
317         GEqualFunc _tmp5_;
318         gint _tmp6_;
319         GeeHashSetNode** _tmp7_ = NULL;
320         self = (GeeHashSet*) gee_abstract_set_construct (object_type, g_type, (GBoxedCopyFunc) g_dup_func, g_destroy_func);
321         self->priv->g_type = g_type;
322         self->priv->g_dup_func = g_dup_func;
323         self->priv->g_destroy_func = g_destroy_func;
324         _tmp0_ = hash_func;
325         if (_tmp0_ == NULL) {
326                 GHashFunc _tmp1_ = NULL;
327                 _tmp1_ = gee_functions_get_hash_func_for (g_type);
328                 hash_func = _tmp1_;
329         }
330         _tmp2_ = equal_func;
331         if (_tmp2_ == NULL) {
332                 GEqualFunc _tmp3_ = NULL;
333                 _tmp3_ = gee_functions_get_equal_func_for (g_type);
334                 equal_func = _tmp3_;
335         }
336         _tmp4_ = hash_func;
337         gee_hash_set_set_hash_func (self, _tmp4_);
338         _tmp5_ = equal_func;
339         gee_hash_set_set_equal_func (self, _tmp5_);
340         self->priv->_array_size = GEE_HASH_SET_MIN_SIZE;
341         _tmp6_ = self->priv->_array_size;
342         _tmp7_ = g_new0 (GeeHashSetNode*, _tmp6_ + 1);
343         self->priv->_nodes = (_vala_array_free (self->priv->_nodes, self->priv->_nodes_length1, (GDestroyNotify) gee_hash_set_node_free), NULL);
344         self->priv->_nodes = _tmp7_;
345         self->priv->_nodes_length1 = _tmp6_;
346         self->priv->__nodes_size_ = self->priv->_nodes_length1;
347         return self;
348 }
349
350
351 GeeHashSet* gee_hash_set_new (GType g_type, GBoxedCopyFunc g_dup_func, GDestroyNotify g_destroy_func, GHashFunc hash_func, GEqualFunc equal_func) {
352         return gee_hash_set_construct (GEE_TYPE_HASH_SET, g_type, g_dup_func, g_destroy_func, hash_func, equal_func);
353 }
354
355
356 static GeeHashSetNode** gee_hash_set_lookup_node (GeeHashSet* self, gconstpointer key) {
357         GeeHashSetNode** result = NULL;
358         GHashFunc _tmp0_;
359         GHashFunc _tmp1_;
360         gconstpointer _tmp2_;
361         guint _tmp3_ = 0U;
362         guint hash_value;
363         GeeHashSetNode** _tmp4_;
364         gint _tmp4__length1;
365         guint _tmp5_;
366         gint _tmp6_;
367         GeeHashSetNode** node;
368         GeeHashSetNode** _tmp22_;
369         g_return_val_if_fail (self != NULL, NULL);
370         _tmp0_ = gee_hash_set_get_hash_func (self);
371         _tmp1_ = _tmp0_;
372         _tmp2_ = key;
373         _tmp3_ = _tmp1_ (_tmp2_);
374         hash_value = _tmp3_;
375         _tmp4_ = self->priv->_nodes;
376         _tmp4__length1 = self->priv->_nodes_length1;
377         _tmp5_ = hash_value;
378         _tmp6_ = self->priv->_array_size;
379         node = &_tmp4_[_tmp5_ % _tmp6_];
380         while (TRUE) {
381                 gboolean _tmp7_ = FALSE;
382                 GeeHashSetNode** _tmp8_;
383                 gboolean _tmp20_;
384                 GeeHashSetNode** _tmp21_;
385                 _tmp8_ = node;
386                 if ((*_tmp8_) != NULL) {
387                         gboolean _tmp9_ = FALSE;
388                         guint _tmp10_;
389                         GeeHashSetNode** _tmp11_;
390                         guint _tmp12_;
391                         gboolean _tmp19_;
392                         _tmp10_ = hash_value;
393                         _tmp11_ = node;
394                         _tmp12_ = (*_tmp11_)->key_hash;
395                         if (_tmp10_ != _tmp12_) {
396                                 _tmp9_ = TRUE;
397                         } else {
398                                 GEqualFunc _tmp13_;
399                                 GEqualFunc _tmp14_;
400                                 GeeHashSetNode** _tmp15_;
401                                 gconstpointer _tmp16_;
402                                 gconstpointer _tmp17_;
403                                 gboolean _tmp18_ = FALSE;
404                                 _tmp13_ = gee_hash_set_get_equal_func (self);
405                                 _tmp14_ = _tmp13_;
406                                 _tmp15_ = node;
407                                 _tmp16_ = (*_tmp15_)->key;
408                                 _tmp17_ = key;
409                                 _tmp18_ = _tmp14_ (_tmp16_, _tmp17_);
410                                 _tmp9_ = !_tmp18_;
411                         }
412                         _tmp19_ = _tmp9_;
413                         _tmp7_ = _tmp19_;
414                 } else {
415                         _tmp7_ = FALSE;
416                 }
417                 _tmp20_ = _tmp7_;
418                 if (!_tmp20_) {
419                         break;
420                 }
421                 _tmp21_ = node;
422                 node = &(*_tmp21_)->next;
423         }
424         _tmp22_ = node;
425         result = _tmp22_;
426         return result;
427 }
428
429
430 /**
431  * {@inheritDoc}
432  */
433 static gboolean gee_hash_set_real_contains (GeeAbstractCollection* base, gconstpointer key) {
434         GeeHashSet * self;
435         gboolean result = FALSE;
436         gconstpointer _tmp0_;
437         GeeHashSetNode** _tmp1_ = NULL;
438         GeeHashSetNode** node;
439         self = (GeeHashSet*) base;
440         _tmp0_ = key;
441         _tmp1_ = gee_hash_set_lookup_node (self, _tmp0_);
442         node = _tmp1_;
443         result = (*node) != NULL;
444         return result;
445 }
446
447
448 /**
449  * {@inheritDoc}
450  */
451 static GeeIterator* gee_hash_set_real_iterator (GeeAbstractCollection* base) {
452         GeeHashSet * self;
453         GeeIterator* result = NULL;
454         GeeHashSetIterator* _tmp0_;
455         self = (GeeHashSet*) base;
456         _tmp0_ = gee_hash_set_iterator_new (self->priv->g_type, (GBoxedCopyFunc) self->priv->g_dup_func, self->priv->g_destroy_func, self);
457         result = (GeeIterator*) _tmp0_;
458         return result;
459 }
460
461
462 /**
463  * {@inheritDoc}
464  */
465 static gboolean gee_hash_set_real_add (GeeAbstractCollection* base, gconstpointer key) {
466         GeeHashSet * self;
467         gboolean result = FALSE;
468         gconstpointer _tmp0_;
469         GeeHashSetNode** _tmp1_ = NULL;
470         GeeHashSetNode** node;
471         GeeHashSetNode** _tmp2_;
472         self = (GeeHashSet*) base;
473         _tmp0_ = key;
474         _tmp1_ = gee_hash_set_lookup_node (self, _tmp0_);
475         node = _tmp1_;
476         _tmp2_ = node;
477         if ((*_tmp2_) != NULL) {
478                 result = FALSE;
479                 return result;
480         } else {
481                 GHashFunc _tmp3_;
482                 GHashFunc _tmp4_;
483                 gconstpointer _tmp5_;
484                 guint _tmp6_ = 0U;
485                 guint hash_value;
486                 GeeHashSetNode** _tmp7_;
487                 gconstpointer _tmp8_;
488                 gpointer _tmp9_;
489                 guint _tmp10_;
490                 GeeHashSetNode* _tmp11_;
491                 GeeHashSetNode* _tmp12_;
492                 gint _tmp13_;
493                 gint _tmp14_;
494                 _tmp3_ = gee_hash_set_get_hash_func (self);
495                 _tmp4_ = _tmp3_;
496                 _tmp5_ = key;
497                 _tmp6_ = _tmp4_ (_tmp5_);
498                 hash_value = _tmp6_;
499                 _tmp7_ = node;
500                 _tmp8_ = key;
501                 _tmp9_ = ((_tmp8_ != NULL) && (self->priv->g_dup_func != NULL)) ? self->priv->g_dup_func ((gpointer) _tmp8_) : ((gpointer) _tmp8_);
502                 _tmp10_ = hash_value;
503                 _tmp11_ = gee_hash_set_node_new (_tmp9_, _tmp10_);
504                 *_tmp7_ = _tmp11_;
505                 _tmp12_ = *_tmp7_;
506                 _tmp13_ = self->priv->_nnodes;
507                 self->priv->_nnodes = _tmp13_ + 1;
508                 gee_hash_set_resize (self);
509                 _tmp14_ = self->priv->_stamp;
510                 self->priv->_stamp = _tmp14_ + 1;
511                 result = TRUE;
512                 return result;
513         }
514 }
515
516
517 /**
518  * {@inheritDoc}
519  */
520 static gboolean gee_hash_set_real_remove (GeeAbstractCollection* base, gconstpointer key) {
521         GeeHashSet * self;
522         gboolean result = FALSE;
523         gconstpointer _tmp0_;
524         gboolean _tmp1_ = FALSE;
525         gboolean b;
526         gboolean _tmp2_;
527         self = (GeeHashSet*) base;
528         _tmp0_ = key;
529         _tmp1_ = gee_hash_set_remove_helper (self, _tmp0_);
530         b = _tmp1_;
531         _tmp2_ = b;
532         if (_tmp2_) {
533                 gee_hash_set_resize (self);
534         }
535         result = b;
536         return result;
537 }
538
539
540 /**
541  * {@inheritDoc}
542  */
543 static void gee_hash_set_real_clear (GeeAbstractCollection* base) {
544         GeeHashSet * self;
545         self = (GeeHashSet*) base;
546         {
547                 gint i;
548                 i = 0;
549                 {
550                         gboolean _tmp0_;
551                         _tmp0_ = TRUE;
552                         while (TRUE) {
553                                 gboolean _tmp1_;
554                                 gint _tmp3_;
555                                 gint _tmp4_;
556                                 GeeHashSetNode** _tmp5_;
557                                 gint _tmp5__length1;
558                                 gint _tmp6_;
559                                 GeeHashSetNode* _tmp7_;
560                                 GeeHashSetNode* node;
561                                 _tmp1_ = _tmp0_;
562                                 if (!_tmp1_) {
563                                         gint _tmp2_;
564                                         _tmp2_ = i;
565                                         i = _tmp2_ + 1;
566                                 }
567                                 _tmp0_ = FALSE;
568                                 _tmp3_ = i;
569                                 _tmp4_ = self->priv->_array_size;
570                                 if (!(_tmp3_ < _tmp4_)) {
571                                         break;
572                                 }
573                                 _tmp5_ = self->priv->_nodes;
574                                 _tmp5__length1 = self->priv->_nodes_length1;
575                                 _tmp6_ = i;
576                                 _tmp7_ = _tmp5_[_tmp6_];
577                                 _tmp5_[_tmp6_] = NULL;
578                                 node = _tmp7_;
579                                 while (TRUE) {
580                                         GeeHashSetNode* _tmp8_;
581                                         GeeHashSetNode* _tmp9_;
582                                         GeeHashSetNode* _tmp10_;
583                                         GeeHashSetNode* next;
584                                         GeeHashSetNode* _tmp11_;
585                                         GeeHashSetNode* _tmp12_;
586                                         _tmp8_ = node;
587                                         if (!(_tmp8_ != NULL)) {
588                                                 break;
589                                         }
590                                         _tmp9_ = node;
591                                         _tmp10_ = _tmp9_->next;
592                                         _tmp9_->next = NULL;
593                                         next = _tmp10_;
594                                         _tmp11_ = node;
595                                         ((_tmp11_->key == NULL) || (self->priv->g_destroy_func == NULL)) ? NULL : (_tmp11_->key = (self->priv->g_destroy_func (_tmp11_->key), NULL));
596                                         _tmp11_->key = NULL;
597                                         _tmp12_ = next;
598                                         next = NULL;
599                                         _gee_hash_set_node_free0 (node);
600                                         node = _tmp12_;
601                                         _gee_hash_set_node_free0 (next);
602                                 }
603                                 _gee_hash_set_node_free0 (node);
604                         }
605                 }
606         }
607         self->priv->_nnodes = 0;
608         gee_hash_set_resize (self);
609 }
610
611
612 static inline gboolean gee_hash_set_remove_helper (GeeHashSet* self, gconstpointer key) {
613         gboolean result = FALSE;
614         gconstpointer _tmp0_;
615         GeeHashSetNode** _tmp1_ = NULL;
616         GeeHashSetNode** node;
617         GeeHashSetNode** _tmp2_;
618         g_return_val_if_fail (self != NULL, FALSE);
619         _tmp0_ = key;
620         _tmp1_ = gee_hash_set_lookup_node (self, _tmp0_);
621         node = _tmp1_;
622         _tmp2_ = node;
623         if ((*_tmp2_) != NULL) {
624                 GeeHashSetNode** _tmp3_;
625                 GeeHashSetNode** _tmp4_;
626                 GeeHashSetNode* _tmp5_;
627                 GeeHashSetNode* next;
628                 GeeHashSetNode** _tmp6_;
629                 GeeHashSetNode** _tmp7_;
630                 GeeHashSetNode** _tmp8_;
631                 GeeHashSetNode* _tmp9_;
632                 GeeHashSetNode* _tmp10_;
633                 gint _tmp11_;
634                 gint _tmp12_;
635                 _tmp3_ = node;
636                 _vala_assert ((*_tmp3_) != NULL, "*node != null");
637                 _tmp4_ = node;
638                 _tmp5_ = (*_tmp4_)->next;
639                 (*_tmp4_)->next = NULL;
640                 next = _tmp5_;
641                 _tmp6_ = node;
642                 (((*_tmp6_)->key == NULL) || (self->priv->g_destroy_func == NULL)) ? NULL : ((*_tmp6_)->key = (self->priv->g_destroy_func ((*_tmp6_)->key), NULL));
643                 (*_tmp6_)->key = NULL;
644                 _tmp7_ = node;
645                 gee_hash_set_node_free (*_tmp7_);
646                 _tmp8_ = node;
647                 _tmp9_ = next;
648                 next = NULL;
649                 *_tmp8_ = _tmp9_;
650                 _tmp10_ = *_tmp8_;
651                 _tmp11_ = self->priv->_nnodes;
652                 self->priv->_nnodes = _tmp11_ - 1;
653                 _tmp12_ = self->priv->_stamp;
654                 self->priv->_stamp = _tmp12_ + 1;
655                 result = TRUE;
656                 _gee_hash_set_node_free0 (next);
657                 return result;
658         }
659         result = FALSE;
660         return result;
661 }
662
663
664 static void gee_hash_set_resize (GeeHashSet* self) {
665         gboolean _tmp0_ = FALSE;
666         gboolean _tmp1_ = FALSE;
667         gint _tmp2_;
668         gint _tmp3_;
669         gboolean _tmp5_;
670         gboolean _tmp11_;
671         g_return_if_fail (self != NULL);
672         _tmp2_ = self->priv->_array_size;
673         _tmp3_ = self->priv->_nnodes;
674         if (_tmp2_ >= (3 * _tmp3_)) {
675                 gint _tmp4_;
676                 _tmp4_ = self->priv->_array_size;
677                 _tmp1_ = _tmp4_ >= GEE_HASH_SET_MIN_SIZE;
678         } else {
679                 _tmp1_ = FALSE;
680         }
681         _tmp5_ = _tmp1_;
682         if (_tmp5_) {
683                 _tmp0_ = TRUE;
684         } else {
685                 gboolean _tmp6_ = FALSE;
686                 gint _tmp7_;
687                 gint _tmp8_;
688                 gboolean _tmp10_;
689                 _tmp7_ = self->priv->_array_size;
690                 _tmp8_ = self->priv->_nnodes;
691                 if ((3 * _tmp7_) <= _tmp8_) {
692                         gint _tmp9_;
693                         _tmp9_ = self->priv->_array_size;
694                         _tmp6_ = _tmp9_ < GEE_HASH_SET_MAX_SIZE;
695                 } else {
696                         _tmp6_ = FALSE;
697                 }
698                 _tmp10_ = _tmp6_;
699                 _tmp0_ = _tmp10_;
700         }
701         _tmp11_ = _tmp0_;
702         if (_tmp11_) {
703                 gint _tmp12_;
704                 guint _tmp13_ = 0U;
705                 gint new_array_size;
706                 gint _tmp14_;
707                 gint _tmp15_ = 0;
708                 gint _tmp16_;
709                 GeeHashSetNode** _tmp17_ = NULL;
710                 GeeHashSetNode** new_nodes;
711                 gint new_nodes_length1;
712                 gint _new_nodes_size_;
713                 GeeHashSetNode** _tmp43_;
714                 gint _tmp43__length1;
715                 gint _tmp44_;
716                 _tmp12_ = self->priv->_nnodes;
717                 _tmp13_ = g_spaced_primes_closest ((guint) _tmp12_);
718                 new_array_size = (gint) _tmp13_;
719                 _tmp14_ = new_array_size;
720                 _tmp15_ = CLAMP (_tmp14_, GEE_HASH_SET_MIN_SIZE, GEE_HASH_SET_MAX_SIZE);
721                 new_array_size = _tmp15_;
722                 _tmp16_ = new_array_size;
723                 _tmp17_ = g_new0 (GeeHashSetNode*, _tmp16_ + 1);
724                 new_nodes = _tmp17_;
725                 new_nodes_length1 = _tmp16_;
726                 _new_nodes_size_ = new_nodes_length1;
727                 {
728                         gint i;
729                         i = 0;
730                         {
731                                 gboolean _tmp18_;
732                                 _tmp18_ = TRUE;
733                                 while (TRUE) {
734                                         gboolean _tmp19_;
735                                         gint _tmp21_;
736                                         gint _tmp22_;
737                                         GeeHashSetNode* node = NULL;
738                                         GeeHashSetNode* next;
739                                         _tmp19_ = _tmp18_;
740                                         if (!_tmp19_) {
741                                                 gint _tmp20_;
742                                                 _tmp20_ = i;
743                                                 i = _tmp20_ + 1;
744                                         }
745                                         _tmp18_ = FALSE;
746                                         _tmp21_ = i;
747                                         _tmp22_ = self->priv->_array_size;
748                                         if (!(_tmp21_ < _tmp22_)) {
749                                                 break;
750                                         }
751                                         next = NULL;
752                                         {
753                                                 GeeHashSetNode** _tmp23_;
754                                                 gint _tmp23__length1;
755                                                 gint _tmp24_;
756                                                 GeeHashSetNode* _tmp25_;
757                                                 gboolean _tmp26_;
758                                                 _tmp23_ = self->priv->_nodes;
759                                                 _tmp23__length1 = self->priv->_nodes_length1;
760                                                 _tmp24_ = i;
761                                                 _tmp25_ = _tmp23_[_tmp24_];
762                                                 _tmp23_[_tmp24_] = NULL;
763                                                 _gee_hash_set_node_free0 (node);
764                                                 node = _tmp25_;
765                                                 _tmp26_ = TRUE;
766                                                 while (TRUE) {
767                                                         gboolean _tmp27_;
768                                                         GeeHashSetNode* _tmp29_;
769                                                         GeeHashSetNode* _tmp30_;
770                                                         GeeHashSetNode* _tmp31_;
771                                                         GeeHashSetNode* _tmp32_;
772                                                         guint _tmp33_;
773                                                         gint _tmp34_;
774                                                         guint hash_val;
775                                                         GeeHashSetNode* _tmp35_;
776                                                         GeeHashSetNode** _tmp36_;
777                                                         gint _tmp36__length1;
778                                                         guint _tmp37_;
779                                                         GeeHashSetNode* _tmp38_;
780                                                         GeeHashSetNode** _tmp39_;
781                                                         gint _tmp39__length1;
782                                                         guint _tmp40_;
783                                                         GeeHashSetNode* _tmp41_;
784                                                         GeeHashSetNode* _tmp42_;
785                                                         _tmp27_ = _tmp26_;
786                                                         if (!_tmp27_) {
787                                                                 GeeHashSetNode* _tmp28_;
788                                                                 _tmp28_ = next;
789                                                                 next = NULL;
790                                                                 _gee_hash_set_node_free0 (node);
791                                                                 node = _tmp28_;
792                                                         }
793                                                         _tmp26_ = FALSE;
794                                                         _tmp29_ = node;
795                                                         if (!(_tmp29_ != NULL)) {
796                                                                 break;
797                                                         }
798                                                         _tmp30_ = node;
799                                                         _tmp31_ = _tmp30_->next;
800                                                         _tmp30_->next = NULL;
801                                                         _gee_hash_set_node_free0 (next);
802                                                         next = _tmp31_;
803                                                         _tmp32_ = node;
804                                                         _tmp33_ = _tmp32_->key_hash;
805                                                         _tmp34_ = new_array_size;
806                                                         hash_val = _tmp33_ % _tmp34_;
807                                                         _tmp35_ = node;
808                                                         _tmp36_ = new_nodes;
809                                                         _tmp36__length1 = new_nodes_length1;
810                                                         _tmp37_ = hash_val;
811                                                         _tmp38_ = _tmp36_[_tmp37_];
812                                                         _tmp36_[_tmp37_] = NULL;
813                                                         _gee_hash_set_node_free0 (_tmp35_->next);
814                                                         _tmp35_->next = _tmp38_;
815                                                         _tmp39_ = new_nodes;
816                                                         _tmp39__length1 = new_nodes_length1;
817                                                         _tmp40_ = hash_val;
818                                                         _tmp41_ = node;
819                                                         node = NULL;
820                                                         _gee_hash_set_node_free0 (_tmp39_[_tmp40_]);
821                                                         _tmp39_[_tmp40_] = _tmp41_;
822                                                         _tmp42_ = _tmp39_[_tmp40_];
823                                                 }
824                                         }
825                                         _gee_hash_set_node_free0 (next);
826                                         _gee_hash_set_node_free0 (node);
827                                 }
828                         }
829                 }
830                 _tmp43_ = new_nodes;
831                 _tmp43__length1 = new_nodes_length1;
832                 new_nodes = NULL;
833                 self->priv->_nodes = (_vala_array_free (self->priv->_nodes, self->priv->_nodes_length1, (GDestroyNotify) gee_hash_set_node_free), NULL);
834                 self->priv->_nodes = _tmp43_;
835                 self->priv->_nodes_length1 = _tmp43__length1;
836                 self->priv->__nodes_size_ = self->priv->_nodes_length1;
837                 _tmp44_ = new_array_size;
838                 self->priv->_array_size = _tmp44_;
839                 new_nodes = (_vala_array_free (new_nodes, new_nodes_length1, (GDestroyNotify) gee_hash_set_node_free), NULL);
840         }
841 }
842
843
844 static gint gee_hash_set_real_get_size (GeeAbstractCollection* base) {
845         gint result;
846         GeeHashSet* self;
847         gint _tmp0_;
848         self = (GeeHashSet*) base;
849         _tmp0_ = self->priv->_nnodes;
850         result = _tmp0_;
851         return result;
852 }
853
854
855 GHashFunc gee_hash_set_get_hash_func (GeeHashSet* self) {
856         GHashFunc result;
857         GHashFunc _tmp0_;
858         g_return_val_if_fail (self != NULL, NULL);
859         _tmp0_ = self->priv->_hash_func;
860         result = _tmp0_;
861         return result;
862 }
863
864
865 static void gee_hash_set_set_hash_func (GeeHashSet* self, GHashFunc value) {
866         GHashFunc _tmp0_;
867         g_return_if_fail (self != NULL);
868         _tmp0_ = value;
869         self->priv->_hash_func = _tmp0_;
870         g_object_notify ((GObject *) self, "hash-func");
871 }
872
873
874 GEqualFunc gee_hash_set_get_equal_func (GeeHashSet* self) {
875         GEqualFunc result;
876         GEqualFunc _tmp0_;
877         g_return_val_if_fail (self != NULL, NULL);
878         _tmp0_ = self->priv->_equal_func;
879         result = _tmp0_;
880         return result;
881 }
882
883
884 static void gee_hash_set_set_equal_func (GeeHashSet* self, GEqualFunc value) {
885         GEqualFunc _tmp0_;
886         g_return_if_fail (self != NULL);
887         _tmp0_ = value;
888         self->priv->_equal_func = _tmp0_;
889         g_object_notify ((GObject *) self, "equal-func");
890 }
891
892
893 static GeeHashSetNode* gee_hash_set_node_new (gpointer k, guint hash) {
894         GeeHashSetNode* self;
895         gpointer _tmp0_;
896         guint _tmp1_;
897         self = g_slice_new0 (GeeHashSetNode);
898         gee_hash_set_node_instance_init (self);
899         _tmp0_ = k;
900         k = NULL;
901         self->key = _tmp0_;
902         _tmp1_ = hash;
903         self->key_hash = _tmp1_;
904         return self;
905 }
906
907
908 static void gee_hash_set_node_instance_init (GeeHashSetNode * self) {
909 }
910
911
912 static void gee_hash_set_node_free (GeeHashSetNode* self) {
913         _gee_hash_set_node_free0 (self->next);
914         g_slice_free (GeeHashSetNode, self);
915 }
916
917
918 static gpointer _g_object_ref0 (gpointer self) {
919         return self ? g_object_ref (self) : NULL;
920 }
921
922
923 static GeeHashSetIterator* gee_hash_set_iterator_construct (GType object_type, GType g_type, GBoxedCopyFunc g_dup_func, GDestroyNotify g_destroy_func, GeeHashSet* set) {
924         GeeHashSetIterator * self = NULL;
925         GeeHashSet* _tmp0_;
926         GeeHashSet* _tmp1_;
927         GeeHashSet* _tmp2_;
928         gint _tmp3_;
929         g_return_val_if_fail (set != NULL, NULL);
930         self = (GeeHashSetIterator*) g_object_new (object_type, NULL);
931         self->priv->g_type = g_type;
932         self->priv->g_dup_func = g_dup_func;
933         self->priv->g_destroy_func = g_destroy_func;
934         _tmp0_ = set;
935         _tmp1_ = _g_object_ref0 (_tmp0_);
936         _g_object_unref0 (self->priv->_set);
937         self->priv->_set = _tmp1_;
938         _tmp2_ = self->priv->_set;
939         _tmp3_ = _tmp2_->priv->_stamp;
940         self->priv->_stamp = _tmp3_;
941         return self;
942 }
943
944
945 static GeeHashSetIterator* gee_hash_set_iterator_new (GType g_type, GBoxedCopyFunc g_dup_func, GDestroyNotify g_destroy_func, GeeHashSet* set) {
946         return gee_hash_set_iterator_construct (GEE_HASH_SET_TYPE_ITERATOR, g_type, g_dup_func, g_destroy_func, set);
947 }
948
949
950 static gboolean gee_hash_set_iterator_real_next (GeeIterator* base) {
951         GeeHashSetIterator * self;
952         gboolean result = FALSE;
953         gint _tmp0_;
954         GeeHashSet* _tmp1_;
955         gint _tmp2_;
956         gboolean _tmp3_ = FALSE;
957         GeeHashSetNode* _tmp4_;
958         GeeHashSetNode* _tmp5_;
959         self = (GeeHashSetIterator*) base;
960         _tmp0_ = self->priv->_stamp;
961         _tmp1_ = self->priv->_set;
962         _tmp2_ = _tmp1_->priv->_stamp;
963         _vala_assert (_tmp0_ == _tmp2_, "_stamp == _set._stamp");
964         _tmp3_ = gee_iterator_has_next ((GeeIterator*) self);
965         if (!_tmp3_) {
966                 result = FALSE;
967                 return result;
968         }
969         _tmp4_ = self->priv->_next;
970         self->priv->_node = _tmp4_;
971         self->priv->_next = NULL;
972         _tmp5_ = self->priv->_node;
973         result = _tmp5_ != NULL;
974         return result;
975 }
976
977
978 static gboolean gee_hash_set_iterator_real_has_next (GeeIterator* base) {
979         GeeHashSetIterator * self;
980         gboolean result = FALSE;
981         gint _tmp0_;
982         GeeHashSet* _tmp1_;
983         gint _tmp2_;
984         GeeHashSetNode* _tmp3_;
985         GeeHashSetNode* _tmp19_;
986         self = (GeeHashSetIterator*) base;
987         _tmp0_ = self->priv->_stamp;
988         _tmp1_ = self->priv->_set;
989         _tmp2_ = _tmp1_->priv->_stamp;
990         _vala_assert (_tmp0_ == _tmp2_, "_stamp == _set._stamp");
991         _tmp3_ = self->priv->_next;
992         if (_tmp3_ == NULL) {
993                 GeeHashSetNode* _tmp4_;
994                 GeeHashSetNode* _tmp5_;
995                 _tmp4_ = self->priv->_node;
996                 self->priv->_next = _tmp4_;
997                 _tmp5_ = self->priv->_next;
998                 if (_tmp5_ != NULL) {
999                         GeeHashSetNode* _tmp6_;
1000                         GeeHashSetNode* _tmp7_;
1001                         _tmp6_ = self->priv->_next;
1002                         _tmp7_ = _tmp6_->next;
1003                         self->priv->_next = _tmp7_;
1004                 }
1005                 while (TRUE) {
1006                         gboolean _tmp8_ = FALSE;
1007                         GeeHashSetNode* _tmp9_;
1008                         gboolean _tmp13_;
1009                         gint _tmp14_;
1010                         GeeHashSet* _tmp15_;
1011                         GeeHashSetNode** _tmp16_;
1012                         gint _tmp16__length1;
1013                         gint _tmp17_;
1014                         GeeHashSetNode* _tmp18_;
1015                         _tmp9_ = self->priv->_next;
1016                         if (_tmp9_ == NULL) {
1017                                 gint _tmp10_;
1018                                 GeeHashSet* _tmp11_;
1019                                 gint _tmp12_;
1020                                 _tmp10_ = self->priv->_index;
1021                                 _tmp11_ = self->priv->_set;
1022                                 _tmp12_ = _tmp11_->priv->_array_size;
1023                                 _tmp8_ = (_tmp10_ + 1) < _tmp12_;
1024                         } else {
1025                                 _tmp8_ = FALSE;
1026                         }
1027                         _tmp13_ = _tmp8_;
1028                         if (!_tmp13_) {
1029                                 break;
1030                         }
1031                         _tmp14_ = self->priv->_index;
1032                         self->priv->_index = _tmp14_ + 1;
1033                         _tmp15_ = self->priv->_set;
1034                         _tmp16_ = _tmp15_->priv->_nodes;
1035                         _tmp16__length1 = _tmp15_->priv->_nodes_length1;
1036                         _tmp17_ = self->priv->_index;
1037                         _tmp18_ = _tmp16_[_tmp17_];
1038                         self->priv->_next = _tmp18_;
1039                 }
1040         }
1041         _tmp19_ = self->priv->_next;
1042         result = _tmp19_ != NULL;
1043         return result;
1044 }
1045
1046
1047 static gboolean gee_hash_set_iterator_real_first (GeeIterator* base) {
1048         GeeHashSetIterator * self;
1049         gboolean result = FALSE;
1050         gint _tmp0_;
1051         GeeHashSet* _tmp1_;
1052         gint _tmp2_;
1053         GeeHashSet* _tmp3_;
1054         gint _tmp4_;
1055         gint _tmp5_;
1056         gboolean _tmp6_ = FALSE;
1057         self = (GeeHashSetIterator*) base;
1058         _tmp0_ = self->priv->_stamp;
1059         _tmp1_ = self->priv->_set;
1060         _tmp2_ = _tmp1_->priv->_stamp;
1061         _vala_assert (_tmp0_ == _tmp2_, "_stamp == _set._stamp");
1062         _tmp3_ = self->priv->_set;
1063         _tmp4_ = gee_abstract_collection_get_size ((GeeCollection*) _tmp3_);
1064         _tmp5_ = _tmp4_;
1065         if (_tmp5_ == 0) {
1066                 result = FALSE;
1067                 return result;
1068         }
1069         self->priv->_index = -1;
1070         self->priv->_next = NULL;
1071         _tmp6_ = gee_iterator_next ((GeeIterator*) self);
1072         result = _tmp6_;
1073         return result;
1074 }
1075
1076
1077 static gpointer gee_hash_set_iterator_real_get (GeeIterator* base) {
1078         GeeHashSetIterator * self;
1079         gpointer result = NULL;
1080         gint _tmp0_;
1081         GeeHashSet* _tmp1_;
1082         gint _tmp2_;
1083         GeeHashSetNode* _tmp3_;
1084         GeeHashSetNode* _tmp4_;
1085         gconstpointer _tmp5_;
1086         gpointer _tmp6_;
1087         self = (GeeHashSetIterator*) base;
1088         _tmp0_ = self->priv->_stamp;
1089         _tmp1_ = self->priv->_set;
1090         _tmp2_ = _tmp1_->priv->_stamp;
1091         _vala_assert (_tmp0_ == _tmp2_, "_stamp == _set._stamp");
1092         _tmp3_ = self->priv->_node;
1093         _vala_assert (_tmp3_ != NULL, "_node != null");
1094         _tmp4_ = self->priv->_node;
1095         _tmp5_ = _tmp4_->key;
1096         _tmp6_ = ((_tmp5_ != NULL) && (self->priv->g_dup_func != NULL)) ? self->priv->g_dup_func ((gpointer) _tmp5_) : ((gpointer) _tmp5_);
1097         result = _tmp6_;
1098         return result;
1099 }
1100
1101
1102 static void gee_hash_set_iterator_real_remove (GeeIterator* base) {
1103         GeeHashSetIterator * self;
1104         gint _tmp0_;
1105         GeeHashSet* _tmp1_;
1106         gint _tmp2_;
1107         GeeHashSetNode* _tmp3_;
1108         GeeHashSet* _tmp4_;
1109         GeeHashSetNode* _tmp5_;
1110         gconstpointer _tmp6_;
1111         GeeHashSet* _tmp7_;
1112         gint _tmp8_;
1113         self = (GeeHashSetIterator*) base;
1114         _tmp0_ = self->priv->_stamp;
1115         _tmp1_ = self->priv->_set;
1116         _tmp2_ = _tmp1_->priv->_stamp;
1117         _vala_assert (_tmp0_ == _tmp2_, "_stamp == _set._stamp");
1118         _tmp3_ = self->priv->_node;
1119         _vala_assert (_tmp3_ != NULL, "_node != null");
1120         gee_iterator_has_next ((GeeIterator*) self);
1121         _tmp4_ = self->priv->_set;
1122         _tmp5_ = self->priv->_node;
1123         _tmp6_ = _tmp5_->key;
1124         gee_hash_set_remove_helper (_tmp4_, _tmp6_);
1125         self->priv->_node = NULL;
1126         _tmp7_ = self->priv->_set;
1127         _tmp8_ = _tmp7_->priv->_stamp;
1128         self->priv->_stamp = _tmp8_;
1129 }
1130
1131
1132 static void gee_hash_set_iterator_class_init (GeeHashSetIteratorClass * klass) {
1133         gee_hash_set_iterator_parent_class = g_type_class_peek_parent (klass);
1134         g_type_class_add_private (klass, sizeof (GeeHashSetIteratorPrivate));
1135         G_OBJECT_CLASS (klass)->get_property = _vala_gee_hash_set_iterator_get_property;
1136         G_OBJECT_CLASS (klass)->set_property = _vala_gee_hash_set_iterator_set_property;
1137         G_OBJECT_CLASS (klass)->finalize = gee_hash_set_iterator_finalize;
1138         g_object_class_install_property (G_OBJECT_CLASS (klass), GEE_HASH_SET_ITERATOR_G_TYPE, g_param_spec_gtype ("g-type", "type", "type", G_TYPE_NONE, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
1139         g_object_class_install_property (G_OBJECT_CLASS (klass), GEE_HASH_SET_ITERATOR_G_DUP_FUNC, g_param_spec_pointer ("g-dup-func", "dup func", "dup func", G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
1140         g_object_class_install_property (G_OBJECT_CLASS (klass), GEE_HASH_SET_ITERATOR_G_DESTROY_FUNC, g_param_spec_pointer ("g-destroy-func", "destroy func", "destroy func", G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
1141 }
1142
1143
1144 static void gee_hash_set_iterator_gee_iterator_interface_init (GeeIteratorIface * iface) {
1145         gee_hash_set_iterator_gee_iterator_parent_iface = g_type_interface_peek_parent (iface);
1146         iface->next = (gboolean (*)(GeeIterator*)) gee_hash_set_iterator_real_next;
1147         iface->has_next = (gboolean (*)(GeeIterator*)) gee_hash_set_iterator_real_has_next;
1148         iface->first = (gboolean (*)(GeeIterator*)) gee_hash_set_iterator_real_first;
1149         iface->get = (gpointer (*)(GeeIterator*)) gee_hash_set_iterator_real_get;
1150         iface->remove = (void (*)(GeeIterator*)) gee_hash_set_iterator_real_remove;
1151 }
1152
1153
1154 static void gee_hash_set_iterator_instance_init (GeeHashSetIterator * self) {
1155         self->priv = GEE_HASH_SET_ITERATOR_GET_PRIVATE (self);
1156         self->priv->_index = -1;
1157         self->priv->_stamp = 0;
1158 }
1159
1160
1161 static void gee_hash_set_iterator_finalize (GObject* obj) {
1162         GeeHashSetIterator * self;
1163         self = G_TYPE_CHECK_INSTANCE_CAST (obj, GEE_HASH_SET_TYPE_ITERATOR, GeeHashSetIterator);
1164         _g_object_unref0 (self->priv->_set);
1165         G_OBJECT_CLASS (gee_hash_set_iterator_parent_class)->finalize (obj);
1166 }
1167
1168
1169 static GType gee_hash_set_iterator_get_type (void) {
1170         static volatile gsize gee_hash_set_iterator_type_id__volatile = 0;
1171         if (g_once_init_enter (&gee_hash_set_iterator_type_id__volatile)) {
1172                 static const GTypeInfo g_define_type_info = { sizeof (GeeHashSetIteratorClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) gee_hash_set_iterator_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (GeeHashSetIterator), 0, (GInstanceInitFunc) gee_hash_set_iterator_instance_init, NULL };
1173                 static const GInterfaceInfo gee_iterator_info = { (GInterfaceInitFunc) gee_hash_set_iterator_gee_iterator_interface_init, (GInterfaceFinalizeFunc) NULL, NULL};
1174                 GType gee_hash_set_iterator_type_id;
1175                 gee_hash_set_iterator_type_id = g_type_register_static (G_TYPE_OBJECT, "GeeHashSetIterator", &g_define_type_info, 0);
1176                 g_type_add_interface_static (gee_hash_set_iterator_type_id, GEE_TYPE_ITERATOR, &gee_iterator_info);
1177                 g_once_init_leave (&gee_hash_set_iterator_type_id__volatile, gee_hash_set_iterator_type_id);
1178         }
1179         return gee_hash_set_iterator_type_id__volatile;
1180 }
1181
1182
1183 static void _vala_gee_hash_set_iterator_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec) {
1184         GeeHashSetIterator * self;
1185         self = G_TYPE_CHECK_INSTANCE_CAST (object, GEE_HASH_SET_TYPE_ITERATOR, GeeHashSetIterator);
1186         switch (property_id) {
1187                 default:
1188                 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
1189                 break;
1190         }
1191 }
1192
1193
1194 static void _vala_gee_hash_set_iterator_set_property (GObject * object, guint property_id, const GValue * value, GParamSpec * pspec) {
1195         GeeHashSetIterator * self;
1196         self = G_TYPE_CHECK_INSTANCE_CAST (object, GEE_HASH_SET_TYPE_ITERATOR, GeeHashSetIterator);
1197         switch (property_id) {
1198                 case GEE_HASH_SET_ITERATOR_G_TYPE:
1199                 self->priv->g_type = g_value_get_gtype (value);
1200                 break;
1201                 case GEE_HASH_SET_ITERATOR_G_DUP_FUNC:
1202                 self->priv->g_dup_func = g_value_get_pointer (value);
1203                 break;
1204                 case GEE_HASH_SET_ITERATOR_G_DESTROY_FUNC:
1205                 self->priv->g_destroy_func = g_value_get_pointer (value);
1206                 break;
1207                 default:
1208                 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
1209                 break;
1210         }
1211 }
1212
1213
1214 static void gee_hash_set_class_init (GeeHashSetClass * klass) {
1215         gee_hash_set_parent_class = g_type_class_peek_parent (klass);
1216         g_type_class_add_private (klass, sizeof (GeeHashSetPrivate));
1217         GEE_ABSTRACT_COLLECTION_CLASS (klass)->contains = gee_hash_set_real_contains;
1218         GEE_ABSTRACT_COLLECTION_CLASS (klass)->iterator = gee_hash_set_real_iterator;
1219         GEE_ABSTRACT_COLLECTION_CLASS (klass)->add = gee_hash_set_real_add;
1220         GEE_ABSTRACT_COLLECTION_CLASS (klass)->remove = gee_hash_set_real_remove;
1221         GEE_ABSTRACT_COLLECTION_CLASS (klass)->clear = gee_hash_set_real_clear;
1222         GEE_ABSTRACT_COLLECTION_CLASS (klass)->get_size = gee_hash_set_real_get_size;
1223         G_OBJECT_CLASS (klass)->get_property = _vala_gee_hash_set_get_property;
1224         G_OBJECT_CLASS (klass)->set_property = _vala_gee_hash_set_set_property;
1225         G_OBJECT_CLASS (klass)->finalize = gee_hash_set_finalize;
1226         g_object_class_install_property (G_OBJECT_CLASS (klass), GEE_HASH_SET_G_TYPE, g_param_spec_gtype ("g-type", "type", "type", G_TYPE_NONE, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
1227         g_object_class_install_property (G_OBJECT_CLASS (klass), GEE_HASH_SET_G_DUP_FUNC, g_param_spec_pointer ("g-dup-func", "dup func", "dup func", G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
1228         g_object_class_install_property (G_OBJECT_CLASS (klass), GEE_HASH_SET_G_DESTROY_FUNC, g_param_spec_pointer ("g-destroy-func", "destroy func", "destroy func", G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
1229         /**
1230          * {@inheritDoc}
1231          */
1232         g_object_class_install_property (G_OBJECT_CLASS (klass), GEE_HASH_SET_SIZE, g_param_spec_int ("size", "size", "size", G_MININT, G_MAXINT, 0, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE));
1233         /**
1234          * The elements' hash function.
1235          */
1236         g_object_class_install_property (G_OBJECT_CLASS (klass), GEE_HASH_SET_HASH_FUNC, g_param_spec_pointer ("hash-func", "hash-func", "hash-func", G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE));
1237         /**
1238          * The elements' equality testing function.
1239          */
1240         g_object_class_install_property (G_OBJECT_CLASS (klass), GEE_HASH_SET_EQUAL_FUNC, g_param_spec_pointer ("equal-func", "equal-func", "equal-func", G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE));
1241 }
1242
1243
1244 static void gee_hash_set_instance_init (GeeHashSet * self) {
1245         self->priv = GEE_HASH_SET_GET_PRIVATE (self);
1246         self->priv->_stamp = 0;
1247 }
1248
1249
1250 static void gee_hash_set_finalize (GObject* obj) {
1251         GeeHashSet * self;
1252         self = G_TYPE_CHECK_INSTANCE_CAST (obj, GEE_TYPE_HASH_SET, GeeHashSet);
1253         gee_abstract_collection_clear ((GeeAbstractCollection*) self);
1254         self->priv->_nodes = (_vala_array_free (self->priv->_nodes, self->priv->_nodes_length1, (GDestroyNotify) gee_hash_set_node_free), NULL);
1255         G_OBJECT_CLASS (gee_hash_set_parent_class)->finalize (obj);
1256 }
1257
1258
1259 /**
1260  * Hash table implementation of the {@link Set} interface.
1261  *
1262  * This implementation is better fit for highly heterogenous values.
1263  * In case of high value hashes redundancy or higher amount of data prefer using
1264  * tree implementation like {@link TreeSet}.
1265  *
1266  * @see TreeSet
1267  */
1268 GType gee_hash_set_get_type (void) {
1269         static volatile gsize gee_hash_set_type_id__volatile = 0;
1270         if (g_once_init_enter (&gee_hash_set_type_id__volatile)) {
1271                 static const GTypeInfo g_define_type_info = { sizeof (GeeHashSetClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) gee_hash_set_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (GeeHashSet), 0, (GInstanceInitFunc) gee_hash_set_instance_init, NULL };
1272                 GType gee_hash_set_type_id;
1273                 gee_hash_set_type_id = g_type_register_static (GEE_TYPE_ABSTRACT_SET, "GeeHashSet", &g_define_type_info, 0);
1274                 g_once_init_leave (&gee_hash_set_type_id__volatile, gee_hash_set_type_id);
1275         }
1276         return gee_hash_set_type_id__volatile;
1277 }
1278
1279
1280 static void _vala_gee_hash_set_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec) {
1281         GeeHashSet * self;
1282         self = G_TYPE_CHECK_INSTANCE_CAST (object, GEE_TYPE_HASH_SET, GeeHashSet);
1283         switch (property_id) {
1284                 case GEE_HASH_SET_SIZE:
1285                 g_value_set_int (value, gee_abstract_collection_get_size ((GeeAbstractCollection*) self));
1286                 break;
1287                 case GEE_HASH_SET_HASH_FUNC:
1288                 g_value_set_pointer (value, gee_hash_set_get_hash_func (self));
1289                 break;
1290                 case GEE_HASH_SET_EQUAL_FUNC:
1291                 g_value_set_pointer (value, gee_hash_set_get_equal_func (self));
1292                 break;
1293                 default:
1294                 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
1295                 break;
1296         }
1297 }
1298
1299
1300 static void _vala_gee_hash_set_set_property (GObject * object, guint property_id, const GValue * value, GParamSpec * pspec) {
1301         GeeHashSet * self;
1302         self = G_TYPE_CHECK_INSTANCE_CAST (object, GEE_TYPE_HASH_SET, GeeHashSet);
1303         switch (property_id) {
1304                 case GEE_HASH_SET_HASH_FUNC:
1305                 gee_hash_set_set_hash_func (self, g_value_get_pointer (value));
1306                 break;
1307                 case GEE_HASH_SET_EQUAL_FUNC:
1308                 gee_hash_set_set_equal_func (self, g_value_get_pointer (value));
1309                 break;
1310                 case GEE_HASH_SET_G_TYPE:
1311                 self->priv->g_type = g_value_get_gtype (value);
1312                 break;
1313                 case GEE_HASH_SET_G_DUP_FUNC:
1314                 self->priv->g_dup_func = g_value_get_pointer (value);
1315                 break;
1316                 case GEE_HASH_SET_G_DESTROY_FUNC:
1317                 self->priv->g_destroy_func = g_value_get_pointer (value);
1318                 break;
1319                 default:
1320                 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
1321                 break;
1322         }
1323 }
1324
1325
1326 static void _vala_array_destroy (gpointer array, gint array_length, GDestroyNotify destroy_func) {
1327         if ((array != NULL) && (destroy_func != NULL)) {
1328                 int i;
1329                 for (i = 0; i < array_length; i = i + 1) {
1330                         if (((gpointer*) array)[i] != NULL) {
1331                                 destroy_func (((gpointer*) array)[i]);
1332                         }
1333                 }
1334         }
1335 }
1336
1337
1338 static void _vala_array_free (gpointer array, gint array_length, GDestroyNotify destroy_func) {
1339         _vala_array_destroy (array, array_length, destroy_func);
1340         g_free (array);
1341 }
1342
1343
1344