forked from paulovn/pyDAWG
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdawgnode.h
More file actions
64 lines (43 loc) · 1.47 KB
/
Copy pathdawgnode.h
File metadata and controls
64 lines (43 loc) · 1.47 KB
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
/*
This is part of pydawg Python module.
Declaration of nodes/edges of graph.
Author : Wojciech Muła, wojciech_mula@poczta.onet.pl
WWW : http://0x80.pl/proj/pydawg/
License : 3-clauses BSD (see LICENSE)
*/
#ifndef dawgnode_h_included__
#define dawgnode_h_included__
#include "common.h"
struct DAWGNode;
typedef struct DAWGEdge {
DAWG_LETTER_TYPE letter; ///< link label
struct DAWGNode* child; ///< destination
} DAWGEdge;
typedef struct DAWGNode {
uint16_t n; ///< number of outcoming edges
DAWGEdge* next; ///< outcoming edges - always sorted by letter
uint16_t visited; ///< visited (field used while traversing a graph)
bool eow; ///< End-Of-Word marker
#ifdef DAWG_PERFECT_HASHING
int number; ///< number of words reachable from this state
#endif
} DAWGNode;
/* allocate and initialize node */
DAWGNode*
dawgnode_new(void);
/* free memory occupied by node and its internal structures */
void
dawgnode_free(DAWGNode* node);
/* check if node has child connected by edge labelled by letter */
bool PURE
dawgnode_has_child(DAWGNode* node, const DAWG_LETTER_TYPE letter);
/* returns node connected by edge labelled by letter */
DAWGNode* PURE
dawgnode_get_child(DAWGNode* node, const DAWG_LETTER_TYPE letter);
/* adds or replace link */
DAWGNode*
dawgnode_set_child(DAWGNode* node, const DAWG_LETTER_TYPE letter, DAWGNode* child);
/* returns size of node and its internal structures */
size_t PURE
dawgnode_get_size(DAWGNode* node);
#endif