-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStringDict.h
More file actions
54 lines (33 loc) · 817 Bytes
/
StringDict.h
File metadata and controls
54 lines (33 loc) · 817 Bytes
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
//
// Created by Matthieu Rudelle on 26/05/16.
//
#ifndef DEVSEARCH_DB_STRINGDICT_H
#define DEVSEARCH_DB_STRINGDICT_H
#include <string>
#include <map>
using namespace std;
struct trie_node;
typedef std::map<char, trie_node*> child_map;
struct trie_node {
int key;
child_map children;
};
class StringDict {
private:
trie_node *root;
int tempId;
int generateKey();
public:
StringDict();
int add(string text);
int size;
int getKey(string text);
void print();
void print(string prefix, trie_node* node);
int nodeCount();
int nodeCount(trie_node *node);
void sort(int *translation);
int sort(int *translation, trie_node *node, int idStart);
void getBatchKeys(int size, string *texts, int *keysOut);
};
#endif //DEVSEARCH_DB_STRINGDICT_H