457ed791c4eeedb6c54e2698c5c8f56d9a3b39fc
[profile/ivi/libgee.git] / gee / multimap.c
1 /* multimap.c generated by valac 0.18.0, the Vala compiler
2  * generated from multimap.vala, do not modify */
3
4 /* multimap.vala
5  *
6  * Copyright (C) 2009  Ali Sabil
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  *      Ali Sabil <ali.sabil@gmail.com>
24  */
25
26 #include <glib.h>
27 #include <glib-object.h>
28
29
30 #define GEE_TYPE_MULTI_MAP (gee_multi_map_get_type ())
31 #define GEE_MULTI_MAP(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GEE_TYPE_MULTI_MAP, GeeMultiMap))
32 #define GEE_IS_MULTI_MAP(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GEE_TYPE_MULTI_MAP))
33 #define GEE_MULTI_MAP_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), GEE_TYPE_MULTI_MAP, GeeMultiMapIface))
34
35 typedef struct _GeeMultiMap GeeMultiMap;
36 typedef struct _GeeMultiMapIface GeeMultiMapIface;
37
38 #define GEE_TYPE_ITERABLE (gee_iterable_get_type ())
39 #define GEE_ITERABLE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GEE_TYPE_ITERABLE, GeeIterable))
40 #define GEE_IS_ITERABLE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GEE_TYPE_ITERABLE))
41 #define GEE_ITERABLE_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), GEE_TYPE_ITERABLE, GeeIterableIface))
42
43 typedef struct _GeeIterable GeeIterable;
44 typedef struct _GeeIterableIface GeeIterableIface;
45
46 #define GEE_TYPE_ITERATOR (gee_iterator_get_type ())
47 #define GEE_ITERATOR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GEE_TYPE_ITERATOR, GeeIterator))
48 #define GEE_IS_ITERATOR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GEE_TYPE_ITERATOR))
49 #define GEE_ITERATOR_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), GEE_TYPE_ITERATOR, GeeIteratorIface))
50
51 typedef struct _GeeIterator GeeIterator;
52 typedef struct _GeeIteratorIface GeeIteratorIface;
53
54 #define GEE_TYPE_COLLECTION (gee_collection_get_type ())
55 #define GEE_COLLECTION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GEE_TYPE_COLLECTION, GeeCollection))
56 #define GEE_IS_COLLECTION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GEE_TYPE_COLLECTION))
57 #define GEE_COLLECTION_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), GEE_TYPE_COLLECTION, GeeCollectionIface))
58
59 typedef struct _GeeCollection GeeCollection;
60 typedef struct _GeeCollectionIface GeeCollectionIface;
61
62 #define GEE_TYPE_SET (gee_set_get_type ())
63 #define GEE_SET(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GEE_TYPE_SET, GeeSet))
64 #define GEE_IS_SET(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GEE_TYPE_SET))
65 #define GEE_SET_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), GEE_TYPE_SET, GeeSetIface))
66
67 typedef struct _GeeSet GeeSet;
68 typedef struct _GeeSetIface GeeSetIface;
69
70 #define GEE_TYPE_MULTI_SET (gee_multi_set_get_type ())
71 #define GEE_MULTI_SET(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GEE_TYPE_MULTI_SET, GeeMultiSet))
72 #define GEE_IS_MULTI_SET(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GEE_TYPE_MULTI_SET))
73 #define GEE_MULTI_SET_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), GEE_TYPE_MULTI_SET, GeeMultiSetIface))
74
75 typedef struct _GeeMultiSet GeeMultiSet;
76 typedef struct _GeeMultiSetIface GeeMultiSetIface;
77
78 struct _GeeIteratorIface {
79         GTypeInterface parent_iface;
80         gboolean (*next) (GeeIterator* self);
81         gboolean (*has_next) (GeeIterator* self);
82         gboolean (*first) (GeeIterator* self);
83         gpointer (*get) (GeeIterator* self);
84         void (*remove) (GeeIterator* self);
85 };
86
87 struct _GeeIterableIface {
88         GTypeInterface parent_iface;
89         GeeIterator* (*iterator) (GeeIterable* self);
90         GType (*get_element_type) (GeeIterable* self);
91 };
92
93 struct _GeeCollectionIface {
94         GTypeInterface parent_iface;
95         gboolean (*contains) (GeeCollection* self, gconstpointer item);
96         gboolean (*add) (GeeCollection* self, gconstpointer item);
97         gboolean (*remove) (GeeCollection* self, gconstpointer item);
98         void (*clear) (GeeCollection* self);
99         gboolean (*add_all) (GeeCollection* self, GeeCollection* collection);
100         gboolean (*contains_all) (GeeCollection* self, GeeCollection* collection);
101         gboolean (*remove_all) (GeeCollection* self, GeeCollection* collection);
102         gboolean (*retain_all) (GeeCollection* self, GeeCollection* collection);
103         gpointer* (*to_array) (GeeCollection* self, int* result_length1);
104         gint (*get_size) (GeeCollection* self);
105         gboolean (*get_is_empty) (GeeCollection* self);
106         GeeCollection* (*get_read_only_view) (GeeCollection* self);
107 };
108
109 struct _GeeSetIface {
110         GTypeInterface parent_iface;
111         GeeSet* (*get_read_only_view) (GeeSet* self);
112 };
113
114 struct _GeeMultiSetIface {
115         GTypeInterface parent_iface;
116         gint (*count) (GeeMultiSet* self, gconstpointer item);
117 };
118
119 struct _GeeMultiMapIface {
120         GTypeInterface parent_iface;
121         GeeSet* (*get_keys) (GeeMultiMap* self);
122         GeeMultiSet* (*get_all_keys) (GeeMultiMap* self);
123         GeeCollection* (*get_values) (GeeMultiMap* self);
124         gboolean (*contains) (GeeMultiMap* self, gconstpointer key);
125         GeeCollection* (*get) (GeeMultiMap* self, gconstpointer key);
126         void (*set) (GeeMultiMap* self, gconstpointer key, gconstpointer value);
127         gboolean (*remove) (GeeMultiMap* self, gconstpointer key, gconstpointer value);
128         gboolean (*remove_all) (GeeMultiMap* self, gconstpointer key);
129         void (*clear) (GeeMultiMap* self);
130         gint (*get_size) (GeeMultiMap* self);
131 };
132
133
134
135 GType gee_iterator_get_type (void) G_GNUC_CONST;
136 GType gee_iterable_get_type (void) G_GNUC_CONST;
137 GType gee_collection_get_type (void) G_GNUC_CONST;
138 GType gee_set_get_type (void) G_GNUC_CONST;
139 GType gee_multi_set_get_type (void) G_GNUC_CONST;
140 GType gee_multi_map_get_type (void) G_GNUC_CONST;
141 GeeSet* gee_multi_map_get_keys (GeeMultiMap* self);
142 GeeMultiSet* gee_multi_map_get_all_keys (GeeMultiMap* self);
143 GeeCollection* gee_multi_map_get_values (GeeMultiMap* self);
144 gboolean gee_multi_map_contains (GeeMultiMap* self, gconstpointer key);
145 GeeCollection* gee_multi_map_get (GeeMultiMap* self, gconstpointer key);
146 void gee_multi_map_set (GeeMultiMap* self, gconstpointer key, gconstpointer value);
147 gboolean gee_multi_map_remove (GeeMultiMap* self, gconstpointer key, gconstpointer value);
148 gboolean gee_multi_map_remove_all (GeeMultiMap* self, gconstpointer key);
149 void gee_multi_map_clear (GeeMultiMap* self);
150 gint gee_multi_map_get_size (GeeMultiMap* self);
151
152
153 /**
154  * Returns the keys of this multimap as a read-only set.
155  *
156  * @return the keys of the map
157  */
158 GeeSet* gee_multi_map_get_keys (GeeMultiMap* self) {
159         g_return_val_if_fail (self != NULL, NULL);
160         return GEE_MULTI_MAP_GET_INTERFACE (self)->get_keys (self);
161 }
162
163
164 /**
165  * Returns the keys of this multimap as a read-only set.
166  *
167  * @return the keys of the map
168  */
169 GeeMultiSet* gee_multi_map_get_all_keys (GeeMultiMap* self) {
170         g_return_val_if_fail (self != NULL, NULL);
171         return GEE_MULTI_MAP_GET_INTERFACE (self)->get_all_keys (self);
172 }
173
174
175 /**
176  * Returns the values of this map as a read-only collection.
177  *
178  * @return the values of the map
179  */
180 GeeCollection* gee_multi_map_get_values (GeeMultiMap* self) {
181         g_return_val_if_fail (self != NULL, NULL);
182         return GEE_MULTI_MAP_GET_INTERFACE (self)->get_values (self);
183 }
184
185
186 /**
187  * Determines whether this map contains the specified key.
188  *
189  * @param key the key to locate in the map
190  *
191  * @return    ``true`` if key is found, ``false`` otherwise
192  */
193 gboolean gee_multi_map_contains (GeeMultiMap* self, gconstpointer key) {
194         g_return_val_if_fail (self != NULL, FALSE);
195         return GEE_MULTI_MAP_GET_INTERFACE (self)->contains (self, key);
196 }
197
198
199 /**
200  * Returns the values for the specified key in this map.
201  *
202  * @param key the key whose values are to be retrieved
203  *
204  * @return    a Collection of values associated with the given key
205  */
206 GeeCollection* gee_multi_map_get (GeeMultiMap* self, gconstpointer key) {
207         g_return_val_if_fail (self != NULL, NULL);
208         return GEE_MULTI_MAP_GET_INTERFACE (self)->get (self, key);
209 }
210
211
212 /**
213  * Inserts a key/value pair into this map.
214  *
215  * @param key   the key to insert
216  * @param value the value to associate with the key
217  */
218 void gee_multi_map_set (GeeMultiMap* self, gconstpointer key, gconstpointer value) {
219         g_return_if_fail (self != NULL);
220         GEE_MULTI_MAP_GET_INTERFACE (self)->set (self, key, value);
221 }
222
223
224 /**
225  * Removes the specified key/value pair from this multimap.
226  *
227  * @param key   the key to remove from the map
228  * @param value the value to remove from the map
229  *
230  * @return      ``true`` if the map has been changed, ``false`` otherwise
231  */
232 gboolean gee_multi_map_remove (GeeMultiMap* self, gconstpointer key, gconstpointer value) {
233         g_return_val_if_fail (self != NULL, FALSE);
234         return GEE_MULTI_MAP_GET_INTERFACE (self)->remove (self, key, value);
235 }
236
237
238 /**
239  * Removes the specified key and all the associated values from this
240  * multimap.
241  *
242  * @param key the key to remove from the map
243  *
244  * @return    ``true`` if the map has been changed, ``false`` otherwise
245  */
246 gboolean gee_multi_map_remove_all (GeeMultiMap* self, gconstpointer key) {
247         g_return_val_if_fail (self != NULL, FALSE);
248         return GEE_MULTI_MAP_GET_INTERFACE (self)->remove_all (self, key);
249 }
250
251
252 /**
253  * Removes all items from this collection.
254  */
255 void gee_multi_map_clear (GeeMultiMap* self) {
256         g_return_if_fail (self != NULL);
257         GEE_MULTI_MAP_GET_INTERFACE (self)->clear (self);
258 }
259
260
261 gint gee_multi_map_get_size (GeeMultiMap* self) {
262         g_return_val_if_fail (self != NULL, 0);
263         return GEE_MULTI_MAP_GET_INTERFACE (self)->get_size (self);
264 }
265
266
267 static void gee_multi_map_base_init (GeeMultiMapIface * iface) {
268         static gboolean initialized = FALSE;
269         if (!initialized) {
270                 initialized = TRUE;
271                 /**
272                  * The number of key/value pairs in this map.
273                  */
274                 g_object_interface_install_property (iface, 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));
275         }
276 }
277
278
279 /**
280  * A map with multiple values per key.
281  */
282 GType gee_multi_map_get_type (void) {
283         static volatile gsize gee_multi_map_type_id__volatile = 0;
284         if (g_once_init_enter (&gee_multi_map_type_id__volatile)) {
285                 static const GTypeInfo g_define_type_info = { sizeof (GeeMultiMapIface), (GBaseInitFunc) gee_multi_map_base_init, (GBaseFinalizeFunc) NULL, (GClassInitFunc) NULL, (GClassFinalizeFunc) NULL, NULL, 0, 0, (GInstanceInitFunc) NULL, NULL };
286                 GType gee_multi_map_type_id;
287                 gee_multi_map_type_id = g_type_register_static (G_TYPE_INTERFACE, "GeeMultiMap", &g_define_type_info, 0);
288                 g_type_interface_add_prerequisite (gee_multi_map_type_id, G_TYPE_OBJECT);
289                 g_once_init_leave (&gee_multi_map_type_id__volatile, gee_multi_map_type_id);
290         }
291         return gee_multi_map_type_id__volatile;
292 }
293
294
295