00001
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030 #ifndef COLLECTION_H_
00031 #define COLLECTION_H_
00032 #include <glib.h>
00033
00043 typedef enum{
00044 ELEMENTS_TYPE_INTEGER,
00045 ELEMENTS_TYPE_STRING,
00046 ELEMENTS_TYPE_POINTER,
00047 ELEMENTS_TYPE_CUSTOM
00048 } ElementType;
00049
00067 typedef struct {
00068 GHashTable *hTable;
00069 ElementType setType;
00070 }HashSet;
00071
00072
00082 typedef gboolean (* ForeachCallbackFunc) (gpointer data, gpointer userdata);
00083
00110 HashSet *hashSet_new_default(ElementType type);
00111
00125 HashSet *hashSet_new(ElementType type,GHashFunc hash_func, GEqualFunc element_equal_func) ;
00126
00141 HashSet *hashSet_new_full(ElementType type,GHashFunc hash_func, GEqualFunc element_equal_func,
00142 GDestroyNotify element_destroy_func) ;
00143
00144
00154 void hashSet_copy(HashSet *dest, HashSet *src);
00155
00164 guint hashSet_get_size(HashSet *hashSet);
00165
00175 gboolean hashSet_has_element(HashSet *hashSet,gconstpointer element);
00176
00177
00189 gboolean hashSet_add_element(HashSet *hashSet,gpointer element);
00190
00203 void hashSet_remove_all(HashSet *hashSet);
00204
00205
00220 gboolean hashSet_remove_element(HashSet *hashSet,gconstpointer element);
00221
00222
00236 void hashSet_steal_all(HashSet *hashSet);
00237
00252 gboolean hashSet_steal_element(HashSet *hashSet,gconstpointer element);
00253
00273 void hashSet_union(HashSet *result, HashSet *hashSet1, HashSet *hashSet2);
00274
00288 void hashSet_intersect(HashSet *result, HashSet *hashSet1, HashSet *hashSet2);
00289
00311 char* hashSet_to_string(HashSet *hashSet);
00312
00318 void hashSet_destroy(HashSet *hashSet);
00319
00327 int integer_compareFunc(gconstpointer a,gconstpointer b);
00328
00335 #define G_PTR_ARRAY_REMOVE_ALL(array) if (array->len>0) g_ptr_array_remove_range(array,0,array->len)
00336
00346 #define G_ARRAY_CONCAT(dest,src) g_array_append_vals(dest,src->data,src->len)
00347
00354 #define G_ARRAY_REMOVE_ALL(array) if (array->len>0) g_array_remove_range(array,0,array->len)
00355
00373 int g_array_find(GArray *array, gpointer element, gint elementSize,GCompareFunc func);
00374
00386 GArray *g_array_copy(GArray *dest,GArray *src);
00387
00388 #endif
00389