1 /* set.c generated by valac 0.19.0.4-d6d4, the Vala compiler
2  * generated from set.vala, do not modify */
3 
4 /* set.vala
5  *
6  * Copyright (C) 2007  Jürg Billeter
7  *
8  * This library is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Lesser General Public
10  * License as published by the Free Software Foundation; either
11  * version 2.1 of the License, or (at your option) any later version.
12 
13  * This library is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16  * Lesser General Public License for more details.
17 
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with this library; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
21  *
22  * Author:
23  * 	Jürg Billeter <j@bitron.ch>
24  */
25 
26 #include <glib.h>
27 #include <glib-object.h>
28 
29 
30 #define GEE_TYPE_ITERABLE (gee_iterable_get_type ())
31 #define GEE_ITERABLE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GEE_TYPE_ITERABLE, GeeIterable))
32 #define GEE_IS_ITERABLE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GEE_TYPE_ITERABLE))
33 #define GEE_ITERABLE_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), GEE_TYPE_ITERABLE, GeeIterableIface))
34 
35 typedef struct _GeeIterable GeeIterable;
36 typedef struct _GeeIterableIface GeeIterableIface;
37 
38 #define GEE_TYPE_ITERATOR (gee_iterator_get_type ())
39 #define GEE_ITERATOR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GEE_TYPE_ITERATOR, GeeIterator))
40 #define GEE_IS_ITERATOR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GEE_TYPE_ITERATOR))
41 #define GEE_ITERATOR_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), GEE_TYPE_ITERATOR, GeeIteratorIface))
42 
43 typedef struct _GeeIterator GeeIterator;
44 typedef struct _GeeIteratorIface GeeIteratorIface;
45 
46 #define GEE_TYPE_COLLECTION (gee_collection_get_type ())
47 #define GEE_COLLECTION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GEE_TYPE_COLLECTION, GeeCollection))
48 #define GEE_IS_COLLECTION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GEE_TYPE_COLLECTION))
49 #define GEE_COLLECTION_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), GEE_TYPE_COLLECTION, GeeCollectionIface))
50 
51 typedef struct _GeeCollection GeeCollection;
52 typedef struct _GeeCollectionIface GeeCollectionIface;
53 
54 #define GEE_TYPE_SET (gee_set_get_type ())
55 #define GEE_SET(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GEE_TYPE_SET, GeeSet))
56 #define GEE_IS_SET(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GEE_TYPE_SET))
57 #define GEE_SET_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), GEE_TYPE_SET, GeeSetIface))
58 
59 typedef struct _GeeSet GeeSet;
60 typedef struct _GeeSetIface GeeSetIface;
61 
62 #define GEE_TYPE_ABSTRACT_COLLECTION (gee_abstract_collection_get_type ())
63 #define GEE_ABSTRACT_COLLECTION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GEE_TYPE_ABSTRACT_COLLECTION, GeeAbstractCollection))
64 #define GEE_ABSTRACT_COLLECTION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GEE_TYPE_ABSTRACT_COLLECTION, GeeAbstractCollectionClass))
65 #define GEE_IS_ABSTRACT_COLLECTION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GEE_TYPE_ABSTRACT_COLLECTION))
66 #define GEE_IS_ABSTRACT_COLLECTION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GEE_TYPE_ABSTRACT_COLLECTION))
67 #define GEE_ABSTRACT_COLLECTION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GEE_TYPE_ABSTRACT_COLLECTION, GeeAbstractCollectionClass))
68 
69 typedef struct _GeeAbstractCollection GeeAbstractCollection;
70 typedef struct _GeeAbstractCollectionClass GeeAbstractCollectionClass;
71 
72 #define GEE_TYPE_ABSTRACT_SET (gee_abstract_set_get_type ())
73 #define GEE_ABSTRACT_SET(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GEE_TYPE_ABSTRACT_SET, GeeAbstractSet))
74 #define GEE_ABSTRACT_SET_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GEE_TYPE_ABSTRACT_SET, GeeAbstractSetClass))
75 #define GEE_IS_ABSTRACT_SET(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GEE_TYPE_ABSTRACT_SET))
76 #define GEE_IS_ABSTRACT_SET_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GEE_TYPE_ABSTRACT_SET))
77 #define GEE_ABSTRACT_SET_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GEE_TYPE_ABSTRACT_SET, GeeAbstractSetClass))
78 
79 typedef struct _GeeAbstractSet GeeAbstractSet;
80 typedef struct _GeeAbstractSetClass GeeAbstractSetClass;
81 
82 #define GEE_TYPE_HASH_SET (gee_hash_set_get_type ())
83 #define GEE_HASH_SET(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GEE_TYPE_HASH_SET, GeeHashSet))
84 #define GEE_HASH_SET_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GEE_TYPE_HASH_SET, GeeHashSetClass))
85 #define GEE_IS_HASH_SET(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GEE_TYPE_HASH_SET))
86 #define GEE_IS_HASH_SET_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GEE_TYPE_HASH_SET))
87 #define GEE_HASH_SET_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GEE_TYPE_HASH_SET, GeeHashSetClass))
88 
89 typedef struct _GeeHashSet GeeHashSet;
90 typedef struct _GeeHashSetClass GeeHashSetClass;
91 #define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
92 
93 struct _GeeIteratorIface {
94 	GTypeInterface parent_iface;
95 	gboolean (*next) (GeeIterator* self);
96 	gboolean (*has_next) (GeeIterator* self);
97 	gboolean (*first) (GeeIterator* self);
98 	gpointer (*get) (GeeIterator* self);
99 	void (*remove) (GeeIterator* self);
100 };
101 
102 struct _GeeIterableIface {
103 	GTypeInterface parent_iface;
104 	GeeIterator* (*iterator) (GeeIterable* self);
105 	GType (*get_element_type) (GeeIterable* self);
106 };
107 
108 struct _GeeCollectionIface {
109 	GTypeInterface parent_iface;
110 	gboolean (*contains) (GeeCollection* self, gconstpointer item);
111 	gboolean (*add) (GeeCollection* self, gconstpointer item);
112 	gboolean (*remove) (GeeCollection* self, gconstpointer item);
113 	void (*clear) (GeeCollection* self);
114 	gboolean (*add_all) (GeeCollection* self, GeeCollection* collection);
115 	gboolean (*contains_all) (GeeCollection* self, GeeCollection* collection);
116 	gboolean (*remove_all) (GeeCollection* self, GeeCollection* collection);
117 	gboolean (*retain_all) (GeeCollection* self, GeeCollection* collection);
118 	gpointer* (*to_array) (GeeCollection* self, int* result_length1);
119 	gint (*get_size) (GeeCollection* self);
120 	gboolean (*get_is_empty) (GeeCollection* self);
121 	GeeCollection* (*get_read_only_view) (GeeCollection* self);
122 };
123 
124 struct _GeeSetIface {
125 	GTypeInterface parent_iface;
126 	GeeSet* (*get_read_only_view) (GeeSet* self);
127 };
128 
129 
130 
131 GType gee_iterator_get_type (void) G_GNUC_CONST;
132 GType gee_iterable_get_type (void) G_GNUC_CONST;
133 GType gee_collection_get_type (void) G_GNUC_CONST;
134 GType gee_set_get_type (void) G_GNUC_CONST;
135 GeeSet* gee_set_empty (GType g_type, GBoxedCopyFunc g_dup_func, GDestroyNotify g_destroy_func);
136 GeeHashSet* gee_hash_set_new (GType g_type, GBoxedCopyFunc g_dup_func, GDestroyNotify g_destroy_func, GHashFunc hash_func, GEqualFunc equal_func);
137 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);
138 GType gee_abstract_collection_get_type (void) G_GNUC_CONST;
139 GType gee_abstract_set_get_type (void) G_GNUC_CONST;
140 GType gee_hash_set_get_type (void) G_GNUC_CONST;
141 GeeSet* gee_abstract_set_get_read_only_view (GeeAbstractSet* self);
142 GeeSet* gee_set_get_read_only_view (GeeSet* self);
143 
144 
145 /**
146  * Returns an immutable empty set.
147  *
148  * @return an immutable empty set
149  */
gee_set_empty(GType g_type,GBoxedCopyFunc g_dup_func,GDestroyNotify g_destroy_func)150 GeeSet* gee_set_empty (GType g_type, GBoxedCopyFunc g_dup_func, GDestroyNotify g_destroy_func) {
151 	GeeSet* result = NULL;
152 	GeeHashSet* _tmp0_;
153 	GeeHashSet* _tmp1_;
154 	GeeSet* _tmp2_;
155 	GeeSet* _tmp3_;
156 	GeeSet* _tmp4_;
157 	_tmp0_ = gee_hash_set_new (g_type, (GBoxedCopyFunc) g_dup_func, g_destroy_func, NULL, NULL);
158 	_tmp1_ = _tmp0_;
159 	_tmp2_ = gee_abstract_set_get_read_only_view ((GeeAbstractSet*) _tmp1_);
160 	_tmp3_ = _tmp2_;
161 	_tmp4_ = _tmp3_;
162 	_g_object_unref0 (_tmp1_);
163 	result = _tmp4_;
164 	return result;
165 }
166 
167 
gee_set_get_read_only_view(GeeSet * self)168 GeeSet* gee_set_get_read_only_view (GeeSet* self) {
169 	g_return_val_if_fail (self != NULL, NULL);
170 	return GEE_SET_GET_INTERFACE (self)->get_read_only_view (self);
171 }
172 
173 
gee_set_base_init(GeeSetIface * iface)174 static void gee_set_base_init (GeeSetIface * iface) {
175 	static gboolean initialized = FALSE;
176 	if (!initialized) {
177 		initialized = TRUE;
178 		/**
179 		 * The read-only view of this set.
180 		 */
181 		g_object_interface_install_property (iface, g_param_spec_object ("read-only-view", "read-only-view", "read-only-view", GEE_TYPE_SET, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE));
182 	}
183 }
184 
185 
186 /**
187  * A collection without duplicate elements.
188  */
gee_set_get_type(void)189 GType gee_set_get_type (void) {
190 	static volatile gsize gee_set_type_id__volatile = 0;
191 	if (g_once_init_enter (&gee_set_type_id__volatile)) {
192 		static const GTypeInfo g_define_type_info = { sizeof (GeeSetIface), (GBaseInitFunc) gee_set_base_init, (GBaseFinalizeFunc) NULL, (GClassInitFunc) NULL, (GClassFinalizeFunc) NULL, NULL, 0, 0, (GInstanceInitFunc) NULL, NULL };
193 		GType gee_set_type_id;
194 		gee_set_type_id = g_type_register_static (G_TYPE_INTERFACE, "GeeSet", &g_define_type_info, 0);
195 		g_type_interface_add_prerequisite (gee_set_type_id, GEE_TYPE_COLLECTION);
196 		g_once_init_leave (&gee_set_type_id__volatile, gee_set_type_id);
197 	}
198 	return gee_set_type_id__volatile;
199 }
200 
201 
202 
203