1 /* hashset.c generated by valac 0.18.0, the Vala compiler
2 * generated from hashset.vala, do not modify */
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
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.
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.
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
25 * Jürg Billeter <j@bitron.ch>
29 #include <glib-object.h>
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))
37 typedef struct _GeeIterable GeeIterable;
38 typedef struct _GeeIterableIface GeeIterableIface;
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))
45 typedef struct _GeeIterator GeeIterator;
46 typedef struct _GeeIteratorIface GeeIteratorIface;
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))
53 typedef struct _GeeCollection GeeCollection;
54 typedef struct _GeeCollectionIface GeeCollectionIface;
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))
63 typedef struct _GeeAbstractCollection GeeAbstractCollection;
64 typedef struct _GeeAbstractCollectionClass GeeAbstractCollectionClass;
65 typedef struct _GeeAbstractCollectionPrivate GeeAbstractCollectionPrivate;
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))
72 typedef struct _GeeSet GeeSet;
73 typedef struct _GeeSetIface GeeSetIface;
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))
82 typedef struct _GeeAbstractSet GeeAbstractSet;
83 typedef struct _GeeAbstractSetClass GeeAbstractSetClass;
84 typedef struct _GeeAbstractSetPrivate GeeAbstractSetPrivate;
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))
93 typedef struct _GeeHashSet GeeHashSet;
94 typedef struct _GeeHashSetClass GeeHashSetClass;
95 typedef struct _GeeHashSetPrivate GeeHashSetPrivate;
96 typedef struct _GeeHashSetNode GeeHashSetNode;
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))
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);
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);
121 struct _GeeIterableIface {
122 GTypeInterface parent_iface;
123 GeeIterator* (*iterator) (GeeIterable* self);
124 GType (*get_element_type) (GeeIterable* self);
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);
143 struct _GeeAbstractCollection {
144 GObject parent_instance;
145 GeeAbstractCollectionPrivate * priv;
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);
165 struct _GeeSetIface {
166 GTypeInterface parent_iface;
167 GeeSet* (*get_read_only_view) (GeeSet* self);
170 struct _GeeAbstractSet {
171 GeeAbstractCollection parent_instance;
172 GeeAbstractSetPrivate * priv;
175 struct _GeeAbstractSetClass {
176 GeeAbstractCollectionClass parent_class;
177 GeeSet* (*get_read_only_view) (GeeAbstractSet* self);
181 GeeAbstractSet parent_instance;
182 GeeHashSetPrivate * priv;
185 struct _GeeHashSetClass {
186 GeeAbstractSetClass parent_class;
189 struct _GeeHashSetPrivate {
191 GBoxedCopyFunc g_dup_func;
192 GDestroyNotify g_destroy_func;
193 GHashFunc _hash_func;
194 GEqualFunc _equal_func;
197 GeeHashSetNode** _nodes;
203 struct _GeeHashSetNode {
205 GeeHashSetNode* next;
209 struct _GeeHashSetIterator {
210 GObject parent_instance;
211 GeeHashSetIteratorPrivate * priv;
214 struct _GeeHashSetIteratorClass {
215 GObjectClass parent_class;
218 struct _GeeHashSetIteratorPrivate {
220 GBoxedCopyFunc g_dup_func;
221 GDestroyNotify g_destroy_func;
224 GeeHashSetNode* _node;
225 GeeHashSetNode* _next;
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;
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))
244 GEE_HASH_SET_DUMMY_PROPERTY,
246 GEE_HASH_SET_G_DUP_FUNC,
247 GEE_HASH_SET_G_DESTROY_FUNC,
249 GEE_HASH_SET_HASH_FUNC,
250 GEE_HASH_SET_EQUAL_FUNC
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))
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
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);
304 * Constructs a new, empty hash set.
306 * If not provided, the functions parameters are requested to the
307 * {@link Functions} function factory methods.
309 * @param hash_func an optional hash function
310 * @param equal_func an optional equality testing function
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;
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;
325 if (_tmp0_ == NULL) {
326 GHashFunc _tmp1_ = NULL;
327 _tmp1_ = gee_functions_get_hash_func_for (g_type);
331 if (_tmp2_ == NULL) {
332 GEqualFunc _tmp3_ = NULL;
333 _tmp3_ = gee_functions_get_equal_func_for (g_type);
337 gee_hash_set_set_hash_func (self, _tmp4_);
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;
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);
356 static GeeHashSetNode** gee_hash_set_lookup_node (GeeHashSet* self, gconstpointer key) {
357 GeeHashSetNode** result = NULL;
360 gconstpointer _tmp2_;
363 GeeHashSetNode** _tmp4_;
367 GeeHashSetNode** node;
368 GeeHashSetNode** _tmp22_;
369 g_return_val_if_fail (self != NULL, NULL);
370 _tmp0_ = gee_hash_set_get_hash_func (self);
373 _tmp3_ = _tmp1_ (_tmp2_);
375 _tmp4_ = self->priv->_nodes;
376 _tmp4__length1 = self->priv->_nodes_length1;
378 _tmp6_ = self->priv->_array_size;
379 node = &_tmp4_[_tmp5_ % _tmp6_];
381 gboolean _tmp7_ = FALSE;
382 GeeHashSetNode** _tmp8_;
384 GeeHashSetNode** _tmp21_;
386 if ((*_tmp8_) != NULL) {
387 gboolean _tmp9_ = FALSE;
389 GeeHashSetNode** _tmp11_;
392 _tmp10_ = hash_value;
394 _tmp12_ = (*_tmp11_)->key_hash;
395 if (_tmp10_ != _tmp12_) {
400 GeeHashSetNode** _tmp15_;
401 gconstpointer _tmp16_;
402 gconstpointer _tmp17_;
403 gboolean _tmp18_ = FALSE;
404 _tmp13_ = gee_hash_set_get_equal_func (self);
407 _tmp16_ = (*_tmp15_)->key;
409 _tmp18_ = _tmp14_ (_tmp16_, _tmp17_);
422 node = &(*_tmp21_)->next;
433 static gboolean gee_hash_set_real_contains (GeeAbstractCollection* base, gconstpointer key) {
435 gboolean result = FALSE;
436 gconstpointer _tmp0_;
437 GeeHashSetNode** _tmp1_ = NULL;
438 GeeHashSetNode** node;
439 self = (GeeHashSet*) base;
441 _tmp1_ = gee_hash_set_lookup_node (self, _tmp0_);
443 result = (*node) != NULL;
451 static GeeIterator* gee_hash_set_real_iterator (GeeAbstractCollection* base) {
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_;
465 static gboolean gee_hash_set_real_add (GeeAbstractCollection* base, gconstpointer key) {
467 gboolean result = FALSE;
468 gconstpointer _tmp0_;
469 GeeHashSetNode** _tmp1_ = NULL;
470 GeeHashSetNode** node;
471 GeeHashSetNode** _tmp2_;
472 self = (GeeHashSet*) base;
474 _tmp1_ = gee_hash_set_lookup_node (self, _tmp0_);
477 if ((*_tmp2_) != NULL) {
483 gconstpointer _tmp5_;
486 GeeHashSetNode** _tmp7_;
487 gconstpointer _tmp8_;
490 GeeHashSetNode* _tmp11_;
491 GeeHashSetNode* _tmp12_;
494 _tmp3_ = gee_hash_set_get_hash_func (self);
497 _tmp6_ = _tmp4_ (_tmp5_);
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_);
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;
520 static gboolean gee_hash_set_real_remove (GeeAbstractCollection* base, gconstpointer key) {
522 gboolean result = FALSE;
523 gconstpointer _tmp0_;
524 gboolean _tmp1_ = FALSE;
527 self = (GeeHashSet*) base;
529 _tmp1_ = gee_hash_set_remove_helper (self, _tmp0_);
533 gee_hash_set_resize (self);
543 static void gee_hash_set_real_clear (GeeAbstractCollection* base) {
545 self = (GeeHashSet*) base;
556 GeeHashSetNode** _tmp5_;
559 GeeHashSetNode* _tmp7_;
560 GeeHashSetNode* node;
569 _tmp4_ = self->priv->_array_size;
570 if (!(_tmp3_ < _tmp4_)) {
573 _tmp5_ = self->priv->_nodes;
574 _tmp5__length1 = self->priv->_nodes_length1;
576 _tmp7_ = _tmp5_[_tmp6_];
577 _tmp5_[_tmp6_] = NULL;
580 GeeHashSetNode* _tmp8_;
581 GeeHashSetNode* _tmp9_;
582 GeeHashSetNode* _tmp10_;
583 GeeHashSetNode* next;
584 GeeHashSetNode* _tmp11_;
585 GeeHashSetNode* _tmp12_;
587 if (!(_tmp8_ != NULL)) {
591 _tmp10_ = _tmp9_->next;
595 ((_tmp11_->key == NULL) || (self->priv->g_destroy_func == NULL)) ? NULL : (_tmp11_->key = (self->priv->g_destroy_func (_tmp11_->key), NULL));
599 _gee_hash_set_node_free0 (node);
601 _gee_hash_set_node_free0 (next);
603 _gee_hash_set_node_free0 (node);
607 self->priv->_nnodes = 0;
608 gee_hash_set_resize (self);
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);
620 _tmp1_ = gee_hash_set_lookup_node (self, _tmp0_);
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_;
636 _vala_assert ((*_tmp3_) != NULL, "*node != null");
638 _tmp5_ = (*_tmp4_)->next;
639 (*_tmp4_)->next = NULL;
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;
645 gee_hash_set_node_free (*_tmp7_);
651 _tmp11_ = self->priv->_nnodes;
652 self->priv->_nnodes = _tmp11_ - 1;
653 _tmp12_ = self->priv->_stamp;
654 self->priv->_stamp = _tmp12_ + 1;
656 _gee_hash_set_node_free0 (next);
664 static void gee_hash_set_resize (GeeHashSet* self) {
665 gboolean _tmp0_ = FALSE;
666 gboolean _tmp1_ = FALSE;
671 g_return_if_fail (self != NULL);
672 _tmp2_ = self->priv->_array_size;
673 _tmp3_ = self->priv->_nnodes;
674 if (_tmp2_ >= (3 * _tmp3_)) {
676 _tmp4_ = self->priv->_array_size;
677 _tmp1_ = _tmp4_ >= GEE_HASH_SET_MIN_SIZE;
685 gboolean _tmp6_ = FALSE;
689 _tmp7_ = self->priv->_array_size;
690 _tmp8_ = self->priv->_nnodes;
691 if ((3 * _tmp7_) <= _tmp8_) {
693 _tmp9_ = self->priv->_array_size;
694 _tmp6_ = _tmp9_ < GEE_HASH_SET_MAX_SIZE;
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;
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);
725 new_nodes_length1 = _tmp16_;
726 _new_nodes_size_ = new_nodes_length1;
737 GeeHashSetNode* node = NULL;
738 GeeHashSetNode* next;
747 _tmp22_ = self->priv->_array_size;
748 if (!(_tmp21_ < _tmp22_)) {
753 GeeHashSetNode** _tmp23_;
754 gint _tmp23__length1;
756 GeeHashSetNode* _tmp25_;
758 _tmp23_ = self->priv->_nodes;
759 _tmp23__length1 = self->priv->_nodes_length1;
761 _tmp25_ = _tmp23_[_tmp24_];
762 _tmp23_[_tmp24_] = NULL;
763 _gee_hash_set_node_free0 (node);
768 GeeHashSetNode* _tmp29_;
769 GeeHashSetNode* _tmp30_;
770 GeeHashSetNode* _tmp31_;
771 GeeHashSetNode* _tmp32_;
775 GeeHashSetNode* _tmp35_;
776 GeeHashSetNode** _tmp36_;
777 gint _tmp36__length1;
779 GeeHashSetNode* _tmp38_;
780 GeeHashSetNode** _tmp39_;
781 gint _tmp39__length1;
783 GeeHashSetNode* _tmp41_;
784 GeeHashSetNode* _tmp42_;
787 GeeHashSetNode* _tmp28_;
790 _gee_hash_set_node_free0 (node);
795 if (!(_tmp29_ != NULL)) {
799 _tmp31_ = _tmp30_->next;
800 _tmp30_->next = NULL;
801 _gee_hash_set_node_free0 (next);
804 _tmp33_ = _tmp32_->key_hash;
805 _tmp34_ = new_array_size;
806 hash_val = _tmp33_ % _tmp34_;
809 _tmp36__length1 = new_nodes_length1;
811 _tmp38_ = _tmp36_[_tmp37_];
812 _tmp36_[_tmp37_] = NULL;
813 _gee_hash_set_node_free0 (_tmp35_->next);
814 _tmp35_->next = _tmp38_;
816 _tmp39__length1 = new_nodes_length1;
820 _gee_hash_set_node_free0 (_tmp39_[_tmp40_]);
821 _tmp39_[_tmp40_] = _tmp41_;
822 _tmp42_ = _tmp39_[_tmp40_];
825 _gee_hash_set_node_free0 (next);
826 _gee_hash_set_node_free0 (node);
831 _tmp43__length1 = new_nodes_length1;
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);
844 static gint gee_hash_set_real_get_size (GeeAbstractCollection* base) {
848 self = (GeeHashSet*) base;
849 _tmp0_ = self->priv->_nnodes;
855 GHashFunc gee_hash_set_get_hash_func (GeeHashSet* self) {
858 g_return_val_if_fail (self != NULL, NULL);
859 _tmp0_ = self->priv->_hash_func;
865 static void gee_hash_set_set_hash_func (GeeHashSet* self, GHashFunc value) {
867 g_return_if_fail (self != NULL);
869 self->priv->_hash_func = _tmp0_;
870 g_object_notify ((GObject *) self, "hash-func");
874 GEqualFunc gee_hash_set_get_equal_func (GeeHashSet* self) {
877 g_return_val_if_fail (self != NULL, NULL);
878 _tmp0_ = self->priv->_equal_func;
884 static void gee_hash_set_set_equal_func (GeeHashSet* self, GEqualFunc value) {
886 g_return_if_fail (self != NULL);
888 self->priv->_equal_func = _tmp0_;
889 g_object_notify ((GObject *) self, "equal-func");
893 static GeeHashSetNode* gee_hash_set_node_new (gpointer k, guint hash) {
894 GeeHashSetNode* self;
897 self = g_slice_new0 (GeeHashSetNode);
898 gee_hash_set_node_instance_init (self);
903 self->key_hash = _tmp1_;
908 static void gee_hash_set_node_instance_init (GeeHashSetNode * self) {
912 static void gee_hash_set_node_free (GeeHashSetNode* self) {
913 _gee_hash_set_node_free0 (self->next);
914 g_slice_free (GeeHashSetNode, self);
918 static gpointer _g_object_ref0 (gpointer self) {
919 return self ? g_object_ref (self) : NULL;
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;
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;
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_;
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);
950 static gboolean gee_hash_set_iterator_real_next (GeeIterator* base) {
951 GeeHashSetIterator * self;
952 gboolean result = FALSE;
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);
969 _tmp4_ = self->priv->_next;
970 self->priv->_node = _tmp4_;
971 self->priv->_next = NULL;
972 _tmp5_ = self->priv->_node;
973 result = _tmp5_ != NULL;
978 static gboolean gee_hash_set_iterator_real_has_next (GeeIterator* base) {
979 GeeHashSetIterator * self;
980 gboolean result = FALSE;
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_;
1006 gboolean _tmp8_ = FALSE;
1007 GeeHashSetNode* _tmp9_;
1010 GeeHashSet* _tmp15_;
1011 GeeHashSetNode** _tmp16_;
1012 gint _tmp16__length1;
1014 GeeHashSetNode* _tmp18_;
1015 _tmp9_ = self->priv->_next;
1016 if (_tmp9_ == NULL) {
1018 GeeHashSet* _tmp11_;
1020 _tmp10_ = self->priv->_index;
1021 _tmp11_ = self->priv->_set;
1022 _tmp12_ = _tmp11_->priv->_array_size;
1023 _tmp8_ = (_tmp10_ + 1) < _tmp12_;
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_;
1041 _tmp19_ = self->priv->_next;
1042 result = _tmp19_ != NULL;
1047 static gboolean gee_hash_set_iterator_real_first (GeeIterator* base) {
1048 GeeHashSetIterator * self;
1049 gboolean result = FALSE;
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_);
1069 self->priv->_index = -1;
1070 self->priv->_next = NULL;
1071 _tmp6_ = gee_iterator_next ((GeeIterator*) self);
1077 static gpointer gee_hash_set_iterator_real_get (GeeIterator* base) {
1078 GeeHashSetIterator * self;
1079 gpointer result = NULL;
1083 GeeHashSetNode* _tmp3_;
1084 GeeHashSetNode* _tmp4_;
1085 gconstpointer _tmp5_;
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_);
1102 static void gee_hash_set_iterator_real_remove (GeeIterator* base) {
1103 GeeHashSetIterator * self;
1107 GeeHashSetNode* _tmp3_;
1109 GeeHashSetNode* _tmp5_;
1110 gconstpointer _tmp6_;
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_;
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));
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;
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;
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);
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);
1179 return gee_hash_set_iterator_type_id__volatile;
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) {
1188 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
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);
1201 case GEE_HASH_SET_ITERATOR_G_DUP_FUNC:
1202 self->priv->g_dup_func = g_value_get_pointer (value);
1204 case GEE_HASH_SET_ITERATOR_G_DESTROY_FUNC:
1205 self->priv->g_destroy_func = g_value_get_pointer (value);
1208 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
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));
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));
1234 * The elements' hash function.
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));
1238 * The elements' equality testing function.
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));
1244 static void gee_hash_set_instance_init (GeeHashSet * self) {
1245 self->priv = GEE_HASH_SET_GET_PRIVATE (self);
1246 self->priv->_stamp = 0;
1250 static void gee_hash_set_finalize (GObject* obj) {
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);
1260 * Hash table implementation of the {@link Set} interface.
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}.
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);
1276 return gee_hash_set_type_id__volatile;
1280 static void _vala_gee_hash_set_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec) {
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));
1287 case GEE_HASH_SET_HASH_FUNC:
1288 g_value_set_pointer (value, gee_hash_set_get_hash_func (self));
1290 case GEE_HASH_SET_EQUAL_FUNC:
1291 g_value_set_pointer (value, gee_hash_set_get_equal_func (self));
1294 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
1300 static void _vala_gee_hash_set_set_property (GObject * object, guint property_id, const GValue * value, GParamSpec * pspec) {
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));
1307 case GEE_HASH_SET_EQUAL_FUNC:
1308 gee_hash_set_set_equal_func (self, g_value_get_pointer (value));
1310 case GEE_HASH_SET_G_TYPE:
1311 self->priv->g_type = g_value_get_gtype (value);
1313 case GEE_HASH_SET_G_DUP_FUNC:
1314 self->priv->g_dup_func = g_value_get_pointer (value);
1316 case GEE_HASH_SET_G_DESTROY_FUNC:
1317 self->priv->g_destroy_func = g_value_get_pointer (value);
1320 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
1326 static void _vala_array_destroy (gpointer array, gint array_length, GDestroyNotify destroy_func) {
1327 if ((array != NULL) && (destroy_func != NULL)) {
1329 for (i = 0; i < array_length; i = i + 1) {
1330 if (((gpointer*) array)[i] != NULL) {
1331 destroy_func (((gpointer*) array)[i]);
1338 static void _vala_array_free (gpointer array, gint array_length, GDestroyNotify destroy_func) {
1339 _vala_array_destroy (array, array_length, destroy_func);