cool / src / lib / GMLMIP0.1 / rules / radixtree.c @ 7c4d2eb4
History  View  Annotate  Download (968 Bytes)
1 
#include "radixtree.h" 

2  
3 
void Radixtree::removeNodes(node* nd) {

4 
if (nd>left)

5 
removeNodes(nd>left); 
6 
if (nd>right)

7 
removeNodes(nd>right); 
8 
delete nd; 
9 
} 
10  
11 
void Radixtree::add_element(vector<bool>& elem) { 
12 
node *index = root; 
13 
for (int i = 0; i < depth; i++) { 
14 
if (elem[i]) {

15 
if (!index>left)

16 
index>left = new node; 
17 
index = index>left; 
18 
} 
19 
else {

20 
if (!index>right)

21 
index>right = new node; 
22 
index = index>right; 
23 
} 
24 
} 
25 
} 
26  
27 
bool Radixtree::contains_element(vector<bool>& elem) { 
28 
node *index = root; 
29 
for (int i = 0; i < depth; i++) { 
30 
if (elem[i])

31 
if (!index>left)

32 
return false; 
33 
else

34 
index = index>left; 
35 
else

36 
if(!index>right)

37 
return false; 
38 
else

39 
index = index>right; 
40 
} 
41 
return true; 
42 
} 
43  
44 
int Radixtree::size_intern(int d, node* nd) { 
45 
int size = 0; 
46 
if (!d)

47 
size = 1;

48 
else {

49 
if (nd>left)

50 
size += size_intern(d1, nd>left);

51 
if (nd>right)

52 
size += size_intern(d1, nd>right);

53 
} 
54 
return size;

55 
} 