-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPatriciaTree.h
57 lines (43 loc) · 995 Bytes
/
PatriciaTree.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
48
49
50
51
52
53
54
55
56
57
#ifndef PATRICIATREE_H_
#define PATRICIATREE_H_
#include <cstdlib>
#include <iostream>
#include "PatriciaNode.h"
enum RetToken {
SUCCESS,
FILE_OPEN,
FILE_I,
FILE_O,
ALLOC,
FREE,
SKIP
};
void StringInit(char *data, size_t l);
const static int bit = 8;
class PatriciaTree {
public:
PatriciaTree(){
size = 0;
root = NULL;
}
~PatriciaTree(){};
void Print();
int GetBit(char *key, int idx);
int EqualKey(char *x, char *y);
PatriciaNode* Search(char *key);
RetToken Insert(char *key, unsigned long long val);
RetToken Load(char *path);
RetToken Save(char *path);
void Clear();
RetToken Delete(char *key);
PatriciaNode *root;
int size;
private:
int FirstDifferentBit(char *x, char *y);
PatriciaNode* SearchI(char *key);
//PatriciaNode* SearchI(PatriciaNode *link, char *key, int d);
void ClearR(PatriciaNode *node);
int GetArray(PatriciaNode *node, PatriciaNode **a, int idx);
RetToken SetArray(PatriciaNode **a, FILE *ofs);
};
#endif /* PATRICIATREE_H_ */