73e250784ffcdcdabe39343fb75209abc56dcb5b
[profile/ivi/libgee.git] / gee / multiset.c
1 /* multiset.c generated by valac 0.18.0, the Vala compiler
2  * generated from multiset.vala, do not modify */
3
4 /* multiset.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_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_MULTI_SET (gee_multi_set_get_type ())
55 #define GEE_MULTI_SET(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GEE_TYPE_MULTI_SET, GeeMultiSet))
56 #define GEE_IS_MULTI_SET(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GEE_TYPE_MULTI_SET))
57 #define GEE_MULTI_SET_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), GEE_TYPE_MULTI_SET, GeeMultiSetIface))
58
59 typedef struct _GeeMultiSet GeeMultiSet;
60 typedef struct _GeeMultiSetIface GeeMultiSetIface;
61
62 struct _GeeIteratorIface {
63         GTypeInterface parent_iface;
64         gboolean (*next) (GeeIterator* self);
65         gboolean (*has_next) (GeeIterator* self);
66         gboolean (*first) (GeeIterator* self);
67         gpointer (*get) (GeeIterator* self);
68         void (*remove) (GeeIterator* self);
69 };
70
71 struct _GeeIterableIface {
72         GTypeInterface parent_iface;
73         GeeIterator* (*iterator) (GeeIterable* self);
74         GType (*get_element_type) (GeeIterable* self);
75 };
76
77 struct _GeeCollectionIface {
78         GTypeInterface parent_iface;
79         gboolean (*contains) (GeeCollection* self, gconstpointer item);
80         gboolean (*add) (GeeCollection* self, gconstpointer item);
81         gboolean (*remove) (GeeCollection* self, gconstpointer item);
82         void (*clear) (GeeCollection* self);
83         gboolean (*add_all) (GeeCollection* self, GeeCollection* collection);
84         gboolean (*contains_all) (GeeCollection* self, GeeCollection* collection);
85         gboolean (*remove_all) (GeeCollection* self, GeeCollection* collection);
86         gboolean (*retain_all) (GeeCollection* self, GeeCollection* collection);
87         gpointer* (*to_array) (GeeCollection* self, int* result_length1);
88         gint (*get_size) (GeeCollection* self);
89         gboolean (*get_is_empty) (GeeCollection* self);
90         GeeCollection* (*get_read_only_view) (GeeCollection* self);
91 };
92
93 struct _GeeMultiSetIface {
94         GTypeInterface parent_iface;
95         gint (*count) (GeeMultiSet* self, gconstpointer item);
96 };
97
98
99
100 GType gee_iterator_get_type (void) G_GNUC_CONST;
101 GType gee_iterable_get_type (void) G_GNUC_CONST;
102 GType gee_collection_get_type (void) G_GNUC_CONST;
103 GType gee_multi_set_get_type (void) G_GNUC_CONST;
104 gint gee_multi_set_count (GeeMultiSet* self, gconstpointer item);
105
106
107 /**
108  * Returns the number of occurences of an item in this multiset.
109  *
110  * @param item the item to count occurences of
111  *
112  * @return     the number of occurences of the item in this multiset.
113  */
114 gint gee_multi_set_count (GeeMultiSet* self, gconstpointer item) {
115         g_return_val_if_fail (self != NULL, 0);
116         return GEE_MULTI_SET_GET_INTERFACE (self)->count (self, item);
117 }
118
119
120 static void gee_multi_set_base_init (GeeMultiSetIface * iface) {
121         static gboolean initialized = FALSE;
122         if (!initialized) {
123                 initialized = TRUE;
124         }
125 }
126
127
128 /**
129  * A collection with duplicate elements.
130  */
131 GType gee_multi_set_get_type (void) {
132         static volatile gsize gee_multi_set_type_id__volatile = 0;
133         if (g_once_init_enter (&gee_multi_set_type_id__volatile)) {
134                 static const GTypeInfo g_define_type_info = { sizeof (GeeMultiSetIface), (GBaseInitFunc) gee_multi_set_base_init, (GBaseFinalizeFunc) NULL, (GClassInitFunc) NULL, (GClassFinalizeFunc) NULL, NULL, 0, 0, (GInstanceInitFunc) NULL, NULL };
135                 GType gee_multi_set_type_id;
136                 gee_multi_set_type_id = g_type_register_static (G_TYPE_INTERFACE, "GeeMultiSet", &g_define_type_info, 0);
137                 g_type_interface_add_prerequisite (gee_multi_set_type_id, GEE_TYPE_COLLECTION);
138                 g_once_init_leave (&gee_multi_set_type_id__volatile, gee_multi_set_type_id);
139         }
140         return gee_multi_set_type_id__volatile;
141 }
142
143
144