-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathpod.h
100 lines (90 loc) · 2.62 KB
/
pod.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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
#ifndef EASY_ALGORITHM_POD_H
#define EASY_ALGORITHM_POD_H
#include <string>
namespace easy_algorithm {
std::string randomString() { // Генерирует String из случайной последовательности [0-9]
std::string ret(100, '\0');
for(int i = 0; i < 100; ++i)
ret[i] = '0' + rand() % 10;
return ret;
}
void delay() {
for(int i = 0; i<100;++i)
i=i;
}
struct PODss { // Структура с маленьким ключом и маленьким значением
PODss() : key(rand()) {}
int key;
char value[1];
bool operator < (PODss& p) { return key < p.key; }
friend std::ostream& operator << (std::ostream& os, const PODss& pod) {
os << pod.key;
return os;
}
friend std::istream& operator >> (std::istream& is, PODss& pod) {
int temp;
is >> temp;
if(!(is.rdstate() & std::ios::failbit))
pod.key = temp;
return is;
}
};
struct PODsb { // Структура с маленьким ключом и большим значением
PODsb() : key(rand()) {}
int key;
char value[10240];
bool operator < (PODsb& p) { return key < p.key; }
friend std::ostream& operator << (std::ostream& os, const PODsb& pod) {
os << pod.key;
return os;
}
friend std::istream& operator >> (std::istream& is, PODsb& pod) {
int temp;
is >> temp;
if(!(is.rdstate() & std::ios::failbit))
pod.key = temp;
return is;
}
};
struct PODbs { // Структура с большим ключом и маленьким значением
PODbs() : key(randomString()) {}
std::string key;
char value[1];
bool operator < (PODbs& p) {
//delay();
return key < p.key;
}
friend std::ostream& operator << (std::ostream& os, const PODbs& pod) {
os << pod.key;
return os;
}
friend std::istream& operator >> (std::istream& is, PODbs& pod) {
std::string temp;
is >> temp;
if(!(is.rdstate() & std::ios::failbit))
pod.key = temp;
return is;
}
};
struct PODbb { // Структура с большим ключом и большим значением
PODbb() : key(randomString()) {}
std::string key;
char value[10240];
bool operator < (PODbb& p) {
//delay();
return key < p.key;
}
friend std::ostream& operator << (std::ostream& os, const PODbb& pod) {
os << pod.key;
return os;
}
friend std::istream& operator >> (std::istream& is, PODbb& pod) {
std::string temp;
is >> temp;
if(!(is.rdstate() & std::ios::failbit))
pod.key = temp;
return is;
}
};
}
#endif