-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
79 lines (64 loc) · 2.16 KB
/
main.cpp
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#include <iostream>
#include <cstdio>
#include "vector.hpp"
#include "bptree_roll.hpp"
#include "database.hpp"
struct String {
char index[65];
String(const String &other) {
for (int i = 0; i < 65; i++)index[i] = other.index[i];
}
String() = default;
friend bool operator>(const String &lhs, const String &rhs) {
return std::string(lhs.index) > std::string(rhs.index);
}
friend bool operator>=(const String &lhs, const String &rhs) {
return std::string(lhs.index) >= std::string(rhs.index);
}
friend bool operator<(const String &lhs, const String &rhs) {
return std::string(lhs.index) < std::string(rhs.index);
}
friend bool operator<=(const String &lhs, const String &rhs) {
return std::string(lhs.index) <= std::string(rhs.index);
}
friend bool operator==(const String &lhs, const String &rhs) {
return std::string(lhs.index) == std::string(rhs.index);
}
friend bool operator!=(const String &lhs, const String &rhs) {
return std::string(lhs.index) != std::string(rhs.index);
}
friend std::ostream &operator<<(std::ostream &os, const String &obj) {
os << obj.index;
return os;
}
};
int main() {
// freopen("5.in", "r", stdin);
// freopen("me.out", "w", stdout);
BPTree<String, int, 100, 100> bpTree("test");
std::pair<String, int> val;
int cnt;
char cmd[10];
int data;
scanf("%d", &cnt);
for (int i = 1; i <= cnt; i++) {
scanf("%s", cmd);
if (cmd[0] == 'i') {
scanf("%s%d", val.first.index, &val.second);
bpTree.insert(val);
} else if (cmd[0] == 'f') {
scanf("%s", val.first.index);
sjtu::vector<int> ans = bpTree.Find(val.first);
if (!ans.empty()) {
for (int i = 0; i < ans.size() - 1; i++)printf("%d ", ans[i]);
printf("%d\n",ans[ans.size()-1]);
} else puts("null");
} else if (cmd[0] == 'd') {
scanf("%s%d", val.first.index, &val.second);
bpTree.remove(val);
}
}
// remove("test_file_tree");
// remove("test_file_leaf");
return 0;
}