gfsmSet.h
Go to the documentation of this file.
1 
2 /*=============================================================================*\
3  * File: gfsmSet.h
4  * Author: Bryan Jurish <moocow.bovine@gmail.com>
5  * Description: finite state machine library
6  *
7  * Copyright (c) 2004-2007 Bryan Jurish.
8  *
9  * This library is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU Lesser General Public
11  * License as published by the Free Software Foundation; either
12  * version 3 of the License, or (at your option) any later version.
13  *
14  * This library is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17  * Lesser General Public License for more details.
18  *
19  * You should have received a copy of the GNU Lesser General Public
20  * License along with this library; if not, write to the Free Software
21  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22  *=============================================================================*/
23 
28 #ifndef _GFSM_SET_H
29 #define _GFSM_SET_H
30 
31 #include <gfsmMem.h>
32 
33 /*======================================================================
34  * Types
35  */
39 typedef GTree gfsmSet;
40 
41 
42 /*======================================================================
43  * Constructors etc.
44  */
46 
47 
49 gfsmSet *gfsm_set_new_full(GCompareDataFunc key_cmp_func, gpointer key_cmp_data, GDestroyNotify key_free_func);
50 
55 gfsmSet *gfsm_set_new(GCompareFunc key_cmp_func);
56 
60 
62 gboolean gfsm_set_copy_foreach_func(gpointer key, gpointer value, gfsmSet *dst);
63 
65 void gfsm_set_clear(gfsmSet *set);
66 
70 #define gfsm_set_free g_tree_destroy
71 
73 
74 
75 /*======================================================================
76  * Accessors
77  */
79 
80 
81 #define gfsm_set_contains(set,key) g_tree_lookup(set,key)
82 
84 #define gfsm_set_insert(set,key) g_tree_insert(set,key,(gpointer)1)
85 
87 #define gfsm_set_size(set) g_tree_nnodes(set)
88 
90 #define gfsm_set_remove(set,key) g_tree_remove(set,key)
91 
93 #define gfsm_set_foreach(set,func,data) g_tree_foreach(set,func,data)
94 
95 
96 /*======================================================================
97  * set: Algebra
98  */
100 
101 
108 gfsmSet *gfsm_set_union(gfsmSet *set1, gfsmSet *set2, gfsmDupFunc dupfunc);
109 
114 
118 
120 
121 
122 /*======================================================================
123  * Converters
124  */
126 
127 
130 GSList *gfsm_set_to_slist(gfsmSet *set);
131 
133 gboolean gfsm_set_to_slist_foreach_func(gpointer key, gpointer value, GSList **dst);
134 
137 void gfsm_set_to_ptr_array(gfsmSet *set, GPtrArray *array);
138 
140 gboolean gfsm_set_to_ptr_array_foreach_func(gpointer key, gpointer value, GPtrArray *dst);
142 
143 /*======================================================================
144  * Debugging
145  */
146 #ifdef GFSM_DEBUG_ENABLED
147 #include <stdio.h>
148 
150 
151 
153 void gfsm_set_print_uint(gfsmSet *set, FILE *f);
154 
156 #endif /* GFSM_DEBUG_ENABLED */
157 
158 //-- inline definitions
159 #ifdef GFSM_INLINE_ENABLED
160 # include <gfsmSet.hi>
161 #endif
162 
163 #endif /* _GFSM_SET_H */