1 /* multimap.c generated by valac 0.18.0, the Vala compiler
2 * generated from multimap.vala, do not modify */
6 * Copyright (C) 2009 Ali Sabil
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.
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.
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
23 * Ali Sabil <ali.sabil@gmail.com>
27 #include <glib-object.h>
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))
35 typedef struct _GeeMultiMap GeeMultiMap;
36 typedef struct _GeeMultiMapIface GeeMultiMapIface;
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))
43 typedef struct _GeeIterable GeeIterable;
44 typedef struct _GeeIterableIface GeeIterableIface;
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))
51 typedef struct _GeeIterator GeeIterator;
52 typedef struct _GeeIteratorIface GeeIteratorIface;
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))
59 typedef struct _GeeCollection GeeCollection;
60 typedef struct _GeeCollectionIface GeeCollectionIface;
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))
67 typedef struct _GeeSet GeeSet;
68 typedef struct _GeeSetIface GeeSetIface;
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))
75 typedef struct _GeeMultiSet GeeMultiSet;
76 typedef struct _GeeMultiSetIface GeeMultiSetIface;
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);
87 struct _GeeIterableIface {
88 GTypeInterface parent_iface;
89 GeeIterator* (*iterator) (GeeIterable* self);
90 GType (*get_element_type) (GeeIterable* self);
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);
109 struct _GeeSetIface {
110 GTypeInterface parent_iface;
111 GeeSet* (*get_read_only_view) (GeeSet* self);
114 struct _GeeMultiSetIface {
115 GTypeInterface parent_iface;
116 gint (*count) (GeeMultiSet* self, gconstpointer item);
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);
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);
154 * Returns the keys of this multimap as a read-only set.
156 * @return the keys of the map
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);
165 * Returns the keys of this multimap as a read-only set.
167 * @return the keys of the map
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);
176 * Returns the values of this map as a read-only collection.
178 * @return the values of the map
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);
187 * Determines whether this map contains the specified key.
189 * @param key the key to locate in the map
191 * @return ``true`` if key is found, ``false`` otherwise
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);
200 * Returns the values for the specified key in this map.
202 * @param key the key whose values are to be retrieved
204 * @return a Collection of values associated with the given key
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);
213 * Inserts a key/value pair into this map.
215 * @param key the key to insert
216 * @param value the value to associate with the key
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);
225 * Removes the specified key/value pair from this multimap.
227 * @param key the key to remove from the map
228 * @param value the value to remove from the map
230 * @return ``true`` if the map has been changed, ``false`` otherwise
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);
239 * Removes the specified key and all the associated values from this
242 * @param key the key to remove from the map
244 * @return ``true`` if the map has been changed, ``false`` otherwise
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);
253 * Removes all items from this collection.
255 void gee_multi_map_clear (GeeMultiMap* self) {
256 g_return_if_fail (self != NULL);
257 GEE_MULTI_MAP_GET_INTERFACE (self)->clear (self);
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);
267 static void gee_multi_map_base_init (GeeMultiMapIface * iface) {
268 static gboolean initialized = FALSE;
272 * The number of key/value pairs in this map.
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));
280 * A map with multiple values per key.
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);
291 return gee_multi_map_type_id__volatile;