Main Page
Related Pages
Data Structures
Files
File List
Globals
src
libgfsm
gfsmArcIndex.h
Go to the documentation of this file.
1
2
/*=============================================================================*\
3
* File: gfsmArcIndex.h
4
* Author: Bryan Jurish <moocow.bovine@gmail.com>
5
* Description: finite state machine library: arc indices
6
*
7
* Copyright (c) 2006-2011 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_ARCINDEX_H
29
#define _GFSM_ARCINDEX_H
30
31
#include <
gfsmArcIter.h
>
32
33
/*======================================================================
34
* ReverseArcIndex
35
*/
37
38
40
49
typedef
GPtrArray
gfsmReverseArcIndex
;
50
55
GFSM_INLINE
56
gfsmReverseArcIndex
*
gfsm_reverse_arc_index_new
(
void
);
57
62
GFSM_INLINE
63
gfsmReverseArcIndex
*
gfsm_reverse_arc_index_sized_new
(
gfsmStateId
n_states);
64
75
gfsmReverseArcIndex
*
gfsm_automaton_to_reverse_arc_index
(
gfsmAutomaton
*fsm,
gfsmReverseArcIndex
*rarcs);
76
78
#define gfsm_automaton_reverse_arc_index gfsm_automaton_to_reverse_arc_index
79
86
void
gfsm_reverse_arc_index_free
(
gfsmReverseArcIndex
*rarcs, gboolean free_lists);
87
89
90
91
/*======================================================================
92
* gfsmFinalWeightIndex
93
*/
95
96
98
typedef
GArray
gfsmWeightVector
;
99
104
GFSM_INLINE
105
gfsmWeightVector
*
gfsm_weight_vector_new
(
void
);
106
111
GFSM_INLINE
112
gfsmWeightVector
*
gfsm_weight_vector_sized_new
(guint size);
113
115
GFSM_INLINE
116
gfsmWeightVector
*
gfsm_weight_vector_copy
(
gfsmWeightVector
*dst,
gfsmWeightVector
*src);
117
119
GFSM_INLINE
120
gfsmWeightVector
*
gfsm_weight_vector_clone
(
gfsmWeightVector
*src);
121
122
124
GFSM_INLINE
125
void
gfsm_weight_vector_resize
(
gfsmWeightVector
*wv, guint size);
126
134
gfsmWeightVector
*
gfsm_automaton_to_final_weight_vector
(
gfsmAutomaton
*fsm,
gfsmWeightVector
*wv);
135
137
GFSM_INLINE
138
void
gfsm_weight_vector_free
(
gfsmWeightVector
*wv);
139
146
gboolean
gfsm_weight_vector_write_bin_handle
(
gfsmWeightVector
*wv,
gfsmIOHandle
*ioh,
gfsmError
**errp);
147
154
gboolean
gfsm_weight_vector_read_bin_handle
(
gfsmWeightVector
*wv,
gfsmIOHandle
*ioh,
gfsmError
**errp);
155
157
158
/*======================================================================
159
* gfsmArcTable
160
*/
162
163
165
typedef
GArray
gfsmArcTable
;
166
168
GFSM_INLINE
169
gfsmArcTable
*
gfsm_arc_table_new
(
void
);
170
172
GFSM_INLINE
173
gfsmArcTable
*
gfsm_arc_table_sized_new
(guint n_arcs);
174
176
GFSM_INLINE
177
void
gfsm_arc_table_resize
(
gfsmArcTable
*tab, guint n_arcs);
178
180
GFSM_INLINE
181
gfsmArcTable
*
gfsm_arc_table_copy
(
gfsmArcTable
*dst,
gfsmArcTable
*src);
182
184
GFSM_INLINE
185
gfsmArcTable
*
gfsm_arc_table_clone
(
gfsmArcTable
*src);
186
188
GFSM_INLINE
189
void
gfsm_arc_table_free
(
gfsmArcTable
*tab);
190
201
gfsmArcTable
*
gfsm_automaton_to_arc_table
(
gfsmAutomaton
*fsm,
gfsmArcTable
*tab);
202
213
gfsmArcTable
*
gfsm_arc_table_append_arclist
(
gfsmArcTable
*tab,
gfsmArcList
*arcs);
214
225
GFSM_INLINE
226
gfsmArcTable
*
gfsm_arc_table_append_arciter
(
gfsmArcTable
*tab,
gfsmArcIter
*ai);
227
239
GFSM_INLINE
240
gfsmArcTable
*
gfsm_arc_table_append_state
(
gfsmArcTable
*tab,
gfsmAutomaton
*fsm,
gfsmStateId
qid);
241
242
244
GFSM_INLINE
245
void
gfsm_arc_table_sort_with_data
(
gfsmArcTable
*tab, GCompareDataFunc compare_func, gpointer data);
246
248
GFSM_INLINE
249
void
gfsm_arc_table_sort_bymask
(
gfsmArcTable
*tab,
gfsmArcCompMask
m,
gfsmSemiring
*sr);
250
256
GFSM_INLINE
257
gfsmArc
*
gfsm_arc_table_seek
(
gfsmArcTable
*tab,
const
gfsmArc
*key, GCompareDataFunc compare_func, gpointer data);
258
264
GFSM_INLINE
265
gfsmArc
*
gfsm_arc_table_seek_bymask
(
gfsmArcTable
*tab,
const
gfsmArc
*key,
gfsmArcCompMask
m,
gfsmSemiring
*sr);
266
273
gboolean
gfsm_arc_table_write_bin_handle
(
gfsmArcTable
*tab,
gfsmIOHandle
*ioh,
gfsmError
**errp);
274
281
gboolean
gfsm_arc_table_read_bin_handle
(
gfsmArcTable
*tab,
gfsmIOHandle
*ioh,
gfsmError
**errp);
282
284
285
/*======================================================================
286
* gfsmArcPTable
287
*/
289
290
292
typedef
GPtrArray
gfsmArcPtrTable
;
293
295
GFSM_INLINE
296
gfsmArcPtrTable
*
gfsm_arc_ptr_table_new
(
void
);
297
299
GFSM_INLINE
300
gfsmArcPtrTable
*
gfsm_arc_ptr_table_sized_new
(guint n_arcs);
301
303
GFSM_INLINE
304
void
gfsm_arc_ptr_table_resize
(
gfsmArcPtrTable
*ptab, guint n_arcs);
305
307
GFSM_INLINE
308
gfsmArcPtrTable
*
gfsm_arc_ptr_table_copy
(
gfsmArcPtrTable
*dst,
gfsmArcPtrTable
*src);
309
311
GFSM_INLINE
312
gfsmArcPtrTable
*
gfsm_arc_ptr_table_clone
(
gfsmArcPtrTable
*src);
313
315
GFSM_INLINE
316
void
gfsm_arc_ptr_table_free
(
gfsmArcPtrTable
*ptab);
317
328
gfsmArcPtrTable
*
gfsm_arc_ptr_table_append_arclist
(
gfsmArcPtrTable
*ptab,
gfsmArcList
*arcs);
329
340
GFSM_INLINE
341
gfsmArcPtrTable
*
gfsm_arc_ptr_table_append_arciter
(
gfsmArcPtrTable
*ptab,
gfsmArcIter
*ai);
342
354
GFSM_INLINE
355
gfsmArcPtrTable
*
gfsm_arc_ptr_table_append_state
(
gfsmArcPtrTable
*ptab,
gfsmAutomaton
*fsm,
gfsmStateId
qid);
356
357
359
GFSM_INLINE
360
void
gfsm_arc_ptr_table_sort_with_data
(
gfsmArcPtrTable
*ptab, GCompareDataFunc compare_func, gpointer data);
361
363
GFSM_INLINE
364
void
gfsm_arc_ptr_table_sort_bymask
(
gfsmArcPtrTable
*ptab,
gfsmArcCompMask
m,
gfsmSemiring
*sr);
365
371
GFSM_INLINE
372
gfsmArc
*
gfsm_arc_ptr_table_seek
(
gfsmArcPtrTable
*ptab,
const
gfsmArc
*key, GCompareDataFunc compare_func, gpointer data);
373
379
GFSM_INLINE
380
gfsmArc
*
gfsm_arc_ptr_table_seek_bymask
(
gfsmArcPtrTable
*ptab,
const
gfsmArc
*key,
gfsmArcCompMask
m,
gfsmSemiring
*sr);
382
383
/*======================================================================
384
* gfsmArcTableIndex
385
*/
387
388
390
typedef
struct
{
391
gfsmArcTable
*
tab
;
392
GPtrArray *
first
;
393
}
gfsmArcTableIndex
;
394
396
GFSM_INLINE
397
gfsmArcTableIndex
*
gfsm_arc_table_index_new
(
void
);
398
400
GFSM_INLINE
401
gfsmArcTableIndex
*
gfsm_arc_table_index_sized_new
(
gfsmStateId
n_states, guint n_arcs);
402
404
GFSM_INLINE
405
void
gfsm_arc_table_index_resize
(
gfsmArcTableIndex
*tab,
gfsmStateId
n_states, guint n_arcs);
406
408
GFSM_INLINE
409
gfsmStateId
gfsm_arc_table_index_n_states
(
gfsmArcTableIndex
*tabx);
410
412
GFSM_INLINE
413
guint
gfsm_arc_table_index_n_arcs
(
gfsmArcTableIndex
*tabx);
414
416
gfsmArcTableIndex
*
gfsm_arc_table_index_copy
(
gfsmArcTableIndex
*dst,
gfsmArcTableIndex
*src);
417
419
GFSM_INLINE
420
gfsmArcTableIndex
*
gfsm_arc_table_index_clone
(
gfsmArcTableIndex
*src);
421
423
GFSM_INLINE
424
void
gfsm_arc_table_index_free
(
gfsmArcTableIndex
*tabx);
425
436
gfsmArcTableIndex
*
gfsm_automaton_to_arc_table_index
(
gfsmAutomaton
*fsm,
gfsmArcTableIndex
*tabx);
437
439
void
gfsm_arc_table_index_sort_with_data
(
gfsmArcTableIndex
*tabx, GCompareDataFunc compare_func, gpointer data);
440
444
GFSM_INLINE
445
void
gfsm_arc_table_index_sort_bymask
(
gfsmArcTableIndex
*tabx,
gfsmArcCompMask
m,
gfsmSemiring
*sr);
446
448
GFSM_INLINE
449
guint
gfsm_arc_table_index_out_degree
(
gfsmArcTableIndex
*tabx,
gfsmStateId
qid);
450
457
gboolean
gfsm_arc_table_index_write_bin_handle
(
gfsmArcTableIndex
*tabx,
gfsmIOHandle
*ioh,
gfsmError
**errp);
458
465
gboolean
gfsm_arc_table_index_read_bin_handle
(
gfsmArcTableIndex
*tabx,
gfsmIOHandle
*ioh,
gfsmError
**errp);
466
468
469
/*======================================================================
470
* gfsmArcRange
471
*/
473
474
476
typedef
struct
{
477
gfsmArc
*
min
;
478
gfsmArc
*
max
;
479
}
gfsmArcRange
;
480
482
GFSM_INLINE
483
void
gfsm_arcrange_open_table_index
(
gfsmArcRange
*range,
gfsmArcTableIndex
*tabx,
gfsmStateId
qid);
484
486
GFSM_INLINE
487
void
gfsm_arcrange_close
(
gfsmArcRange
*range);
488
490
GFSM_INLINE
491
gboolean
gfsm_arcrange_ok
(
gfsmArcRange
*range);
492
494
GFSM_INLINE
495
gfsmArc
*
gfsm_arcrange_arc
(
gfsmArcRange
*range);
496
498
GFSM_INLINE
499
void
gfsm_arcrange_next
(
gfsmArcRange
*range);
500
502
503
/*======================================================================
504
* inline definitions
505
*/
506
#ifdef GFSM_INLINE_ENABLED
507
# include <gfsmArcIndex.hi>
508
#endif
509
510
/*======================================================================
511
* END
512
*/
513
#endif
/* _GFSM_ARCINDEX_H */
Generated on Tue Oct 21 2014 09:44:47 for libgfsm by
1.8.1.2