forked from xerub/acorn
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ac.h
37 lines (27 loc) · 835 Bytes
/
ac.h
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
#ifndef _AC_H_
#define _AC_H_
typedef struct actreenode {
char ch;
int matchid;
struct actreenode *outlink, *faillink;
struct actreenode *children, *sibling;
} ACTREE_NODE, *AC_TREE;
typedef struct {
AC_TREE tree;
int ispreprocessed, errorflag;
int Psize;
int *Plengths;
char *T;
int N, c, initflag, endflag;
AC_TREE w, output;
int prep_new_edges, prep_old_edges, prep_fail_compares;
int num_compares, num_failures, edges_traversed, outlinks_traversed;
} AC_STRUCT;
AC_STRUCT *ac_alloc(void);
int ac_add_string(AC_STRUCT *node, char *P, int M, int id);
int ac_del_string(AC_STRUCT *node, char *P, int M, int id);
int ac_prep(AC_STRUCT *node);
void ac_search_init(AC_STRUCT *node, char *T, int N);
char *ac_search(AC_STRUCT *node, int *length_out, int *id_out);
void ac_free(AC_STRUCT *node);
#endif