-
Notifications
You must be signed in to change notification settings - Fork 0
/
Profile.h
executable file
·50 lines (40 loc) · 1.39 KB
/
Profile.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
// structure for a node of the RB-tree
typedef struct structure{
unsigned long long int qgram; // number that represent the q-gram
int size1; // number of this qgram in the first strings
int size2; // number of this qgram in the second strings
struct structure* sx;
struct structure* dx;
struct structure* father;
bool color; //0 is black and 1 is red
}node;
// class that represent the threshold-qgram profile
// We represent it using an RB-tree
class Profile{
public:
//variables
int threshold;
//constructor
Profile(int thr);
//destructor
~Profile();
//insert a node in the tree
void insert(unsigned long long int qgram, int n_str);
//calculate the distance
unsigned long long int calculateDistance();
//get the total status
int* get_total_status();
//get the number of nodes
unsigned long long int getNumber_of_nodes();
private:
node *root;
node *nil; //special node that represent NULL and is black
bool update; //said if the total_status is update, every time we calculate the distance is update
int *total_status;
unsigned long long int number_of_nodes;
unsigned long long int calculateDistanceRecursive(node *n);
//support for insert
void left_rotate(node *x);
void right_rotate(node *x);
void RB_insert_fixup(node *z);
};