-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathUkkonen.h
47 lines (37 loc) · 1.12 KB
/
Ukkonen.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
38
39
40
41
42
43
44
45
46
47
#pragma once
#include <utility>
#include "Node.h"
#include "Parser.h"
typedef pair<Node*, int> ActivePoint;
typedef pair<bool, Node*> SplitResult;
class BaseUkkonen
{
protected:
Node* dummy;
Node* root;
ActivePoint point;
BaseParser* parser;
ActivePoint update(Node *node, int begin, int end);
ActivePoint canonize(Node *node, int begin, int end);
SplitResult testAndSplit(Node *node, int begin, int end, string word);
void printTree(Node *node, int start, int end, string prefix);
Node* getEdge(Node *node, string symbol);
Node* checkEdge(Node *node, string symbol);
void link(Node *node, int begin, int end, Node *to);
public:
void init();
void build();
void clear();
BaseUkkonen(BaseParser* initParser):
dummy(NULL)
, root(NULL)
, parser(initParser)
{
point.first = NULL;
point.second = 0;
}
virtual ~BaseUkkonen()
{
clear();
}
};