-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTBohr.h
40 lines (33 loc) · 871 Bytes
/
TBohr.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
#include <map>
#include <sstream>
#include <vector>
#include <iostream>
#include <string>
#ifndef TBOHR_H_
#define TBOHR_H_
typedef std::string TLetter;
typedef struct TBohrItem {
std::map<TLetter, TBohrItem*> path;
TBohrItem* sufflink = nullptr;
std::vector<int> success; //pattern id
} TBohrItem;
class TBohr {
public:
TBohr();
TBohrItem* Next(TBohrItem* item, TLetter letter);
TBohrItem* Move(TBohrItem* item, TLetter letter);
void Parse(const std::string&);
void Push(const std::vector<TLetter>&);
void PushLetter(TBohrItem *node, TLetter let, int patid);
TBohrItem* FindSufflink(TBohrItem* child, TBohrItem* parent,
const TLetter letter);
void Search(std::vector<TLetter>&,
std::vector<std::pair<int, int> >&);
void Linkate();
std::vector<int> pieceIndex;
private:
TBohrItem* root;
int patternSize;
int pieces;
};
#endif /* TBOHR_H_ */