libUnihan  0.5.3
collection.h
Go to the documentation of this file.
1 
8 /*
9  * Copyright © 2008 Red Hat, Inc. All rights reserved.
10  * Copyright © 2008 Ding-Yi Chen <dchen at redhat dot com>
11  *
12  * This file is part of the libUnihan Project.
13  *
14  * This library is free software; you can redistribute it and/or
15  * modify it under the terms of the GNU Lesser General Public
16  * License as published by the Free Software Foundation; either
17  * version 2 of the License, or (at your option) any later version.
18  *
19  * This library is distributed in the hope that it will be useful,
20  * but WITHOUT ANY WARRANTY; without even the implied warranty of
21  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22  * GNU Lesser General Public License for more details.
23  *
24  * You should have received a copy of the GNU Lesser General Public
25  * License along with this program; if not, write to the
26  * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
27  * Boston, MA 02111-1307 USA
28  */
29 
30 #ifndef COLLECTION_H_
31 #define COLLECTION_H_
32 #include <glib.h>
33 
43 typedef enum{
48 } ElementType;
49 
67 typedef struct {
68  GHashTable *hTable;
70 }HashSet;
71 
72 
82 typedef gboolean (* ForeachCallbackFunc) (gpointer data, gpointer userdata);
83 
111 
125 HashSet *hashSet_new(ElementType type,GHashFunc hash_func, GEqualFunc element_equal_func) ;
126 
141 HashSet *hashSet_new_full(ElementType type,GHashFunc hash_func, GEqualFunc element_equal_func,
142  GDestroyNotify element_destroy_func) ;
143 
144 
154 void hashSet_copy(HashSet *dest, HashSet *src);
155 
164 guint hashSet_get_size(HashSet *hashSet);
165 
175 gboolean hashSet_has_element(HashSet *hashSet,gconstpointer element);
176 
177 
189 gboolean hashSet_add_element(HashSet *hashSet,gpointer element);
190 
203 void hashSet_remove_all(HashSet *hashSet);
204 
205 
220 gboolean hashSet_remove_element(HashSet *hashSet,gconstpointer element);
221 
222 
236 void hashSet_steal_all(HashSet *hashSet);
237 
252 gboolean hashSet_steal_element(HashSet *hashSet,gconstpointer element);
253 
273 void hashSet_union(HashSet *result, HashSet *hashSet1, HashSet *hashSet2);
274 
288 void hashSet_intersect(HashSet *result, HashSet *hashSet1, HashSet *hashSet2);
289 
311 char* hashSet_to_string(HashSet *hashSet);
312 
318 void hashSet_destroy(HashSet *hashSet);
319 
327 int integer_compareFunc(gconstpointer a,gconstpointer b);
328 
335 #define G_PTR_ARRAY_REMOVE_ALL(array) if (array->len>0) g_ptr_array_remove_range(array,0,array->len)
336 
346 #define G_ARRAY_CONCAT(dest,src) g_array_append_vals(dest,src->data,src->len)
347 
354 #define G_ARRAY_REMOVE_ALL(array) if (array->len>0) g_array_remove_range(array,0,array->len)
355 
373 int g_array_find(GArray *array, gpointer element, gint elementSize,GCompareFunc func);
374 
386 GArray *g_array_copy(GArray *dest,GArray *src);
387 
388 #endif /*COLLECTION_H_*/
389