aboutsummaryrefslogtreecommitdiff
path: root/gfsm/gfsm/src/libgfsm/gfsmStateSet.hi
blob: c2d12482b682d65c5c00163bd4aad84c6f3bb260 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154

/*=============================================================================*\
 * File: gfsmStateSet.hi
 * Author: Bryan Jurish <moocow@ling.uni-potsdam.de>
 * Description: finite state machine library: state sets: inlined definitions
 *
 * Copyright (c) 2004-2007 Bryan Jurish.
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 * 
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 * 
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 *=============================================================================*/

/*======================================================================
 * Methods: Constructors etc.
 */

//--------------------------------------------------------------
// sized_new()
GFSM_INLINE
gfsmStateSet *gfsm_stateset_sized_new(guint isize) 
{
  return g_array_sized_new(FALSE,TRUE,sizeof(gfsmStateId),isize);
}

//--------------------------------------------------------------
// new()
GFSM_INLINE
gfsmStateSet *gfsm_stateset_new(void)
{
  return gfsm_stateset_sized_new(gfsmStateSetDefaultSize);
}

//--------------------------------------------------------------
// new_singleton()
GFSM_INLINE
gfsmStateSet *gfsm_stateset_new_singleton(gfsmStateId id)
{
  gfsmStateSet *sset = gfsm_stateset_new();
  g_array_insert_val(sset,0,id);
  return sset;
}

//--------------------------------------------------------------
// clear()
GFSM_INLINE
void gfsm_stateset_clear(gfsmStateSet *sset)
{
  g_array_set_size(sset,0);
}

//--------------------------------------------------------------
// clone()
GFSM_INLINE
gfsmStateSet *gfsm_stateset_clone(gfsmStateSet *src)
{
  return g_array_append_vals(gfsm_stateset_sized_new(src->len), src->data, src->len);
}

//--------------------------------------------------------------
// free()
GFSM_INLINE
void gfsm_stateset_free(gfsmStateSet *sset)
{
  g_array_free(sset,TRUE);
}

/*======================================================================
 * Methods: Accessors
 */

//--------------------------------------------------------------
// min()
GFSM_INLINE
gfsmStateId gfsm_stateset_min(gfsmStateSet *sset)
{
  return sset->len > 0 ? (*((gfsmStateId*)sset->data)) : gfsmNoState;
}

//--------------------------------------------------------------
// size()
GFSM_INLINE
guint gfsm_stateset_size(gfsmStateSet *sset)
{
  return sset->len;
}

//--------------------------------------------------------------
// find()
//--EXTERN

//--------------------------------------------------------------
// contains()
GFSM_INLINE
gboolean gfsm_stateset_contains(gfsmStateSet *sset, gfsmStateId id)
{
  gfsmStateSetIter sseti = gfsm_stateset_find(sset,id);
  return sseti != NULL && *sseti != gfsmNoState;
}

//--------------------------------------------------------------
// insert()
//--EXTERN

//--------------------------------------------------------------
// union()
//--EXTERN

//--------------------------------------------------------------
// remove()
//--EXTERN

//--------------------------------------------------------------
// equal()
//--EXTERN

/*======================================================================
 * Methods: Utilities
 */

//--------------------------------------------------------------
// hash()
//--EXTERN


//--------------------------------------------------------------
// foreach()
//--EXTERN

/*======================================================================
 * Methods: Automaton access
 */

//--------------------------------------------------------------
// populate()
//--EXTERN

//--------------------------------------------------------------
// has_final_state()
//--EXTERN

//--------------------------------------------------------------
// lookup_final_weight()
//--EXTERN