-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbp-tree.cpp
More file actions
41 lines (35 loc) · 911 Bytes
/
Copy pathbp-tree.cpp
File metadata and controls
41 lines (35 loc) · 911 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
#include "bp-tree.h"
#include <random>
#include <iostream>
#include <vector>
int main() {
// testa o insert
BpTree<int, int>* tree = new BpTree<int, int>(5);
for (int i=0; i<20; i++) {
tree->insert(i, i);
}
// testa o find
for (int i=0; i<20; i++) {
cout << "Node:" << i << " | Value found:" << tree->find(i) << endl;
}
// testa o FindRange
vector<int> respostaFindRange = tree->findRange(10, 17);
for (int i=0; i<respostaFindRange.size(); i++) {
std::cout << "Found in range: " << respostaFindRange[i] << std::endl;
}
// testa o remove
tree->remove(0);
try {
tree->find(0);
} catch (const char* msg) {
std::cout << msg << std::endl;
}
// testa o clear
tree->clear();
try {
tree->find(1);
} catch (const char* msg) {
std::cout << msg << std::endl;
}
return 0;
}