2010-11-06 01:46:53 +02:00
|
|
|
#include <cstdio>
|
2010-10-29 09:26:37 +03:00
|
|
|
#include <cstdlib>
|
2010-06-28 22:01:18 +03:00
|
|
|
#include <iostream>
|
2010-10-29 09:26:37 +03:00
|
|
|
#include <string>
|
|
|
|
|
2011-05-16 02:47:42 +03:00
|
|
|
#include "mph_map.h"
|
|
|
|
|
2010-11-08 22:19:44 +02:00
|
|
|
using std::make_pair;
|
2010-10-29 09:26:37 +03:00
|
|
|
using std::string;
|
2011-05-16 02:47:42 +03:00
|
|
|
using cxxmph::mph_map;
|
2010-06-28 22:01:18 +03:00
|
|
|
|
|
|
|
int main(int argc, char** argv) {
|
2011-05-16 02:47:42 +03:00
|
|
|
mph_map<int64_t, int64_t> b;
|
2012-03-12 05:17:08 +02:00
|
|
|
int32_t num_keys = 1000*10;
|
|
|
|
for (int i = 0; i < num_keys; ++i) {
|
2010-11-08 22:19:44 +02:00
|
|
|
b.insert(make_pair(i, i));
|
|
|
|
}
|
2012-03-15 02:22:40 +02:00
|
|
|
b.rehash(b.size());
|
|
|
|
fprintf(stderr, "Insertion finished\n");
|
|
|
|
for (int i = 0; i < 1000000; ++i) {
|
|
|
|
auto it = b.find(i % num_keys);
|
2012-03-14 09:51:55 +02:00
|
|
|
if (it == b.end()) {
|
|
|
|
std::cerr << "Failed to find " << i << std::endl;
|
|
|
|
exit(-1);
|
|
|
|
}
|
2012-03-15 02:22:40 +02:00
|
|
|
if (it->first != it->second || it->first != i % num_keys) {
|
2012-03-12 05:17:08 +02:00
|
|
|
std::cerr << "Found " << it->first << " looking for " << i << std::endl;
|
|
|
|
exit(-1);
|
|
|
|
}
|
2011-01-21 03:07:46 +02:00
|
|
|
}
|
2012-03-15 02:22:40 +02:00
|
|
|
/*
|
2011-05-16 02:47:42 +03:00
|
|
|
mph_map<string, int> h;
|
2010-10-29 09:26:37 +03:00
|
|
|
h.insert(std::make_pair("-1",-1));
|
2011-05-16 02:47:42 +03:00
|
|
|
mph_map<string, int>::const_iterator it;
|
2010-10-29 09:26:37 +03:00
|
|
|
for (it = h.begin(); it != h.end(); ++it) {
|
2012-03-12 05:17:08 +02:00
|
|
|
if (it->second != -1) exit(-1);
|
2010-06-28 22:01:18 +03:00
|
|
|
}
|
2012-03-12 05:17:08 +02:00
|
|
|
int32_t num_valid = 100;
|
|
|
|
for (int i = 0; i < num_valid; ++i) {
|
2010-10-29 09:26:37 +03:00
|
|
|
char buf[10];
|
|
|
|
snprintf(buf, 10, "%d", i);
|
|
|
|
h.insert(std::make_pair(buf, i));
|
|
|
|
}
|
2010-11-05 04:17:08 +02:00
|
|
|
for (int j = 0; j < 100; ++j) {
|
2010-06-28 22:01:18 +03:00
|
|
|
for (int i = 1000; i > 0; --i) {
|
2010-10-29 09:26:37 +03:00
|
|
|
char buf[10];
|
|
|
|
snprintf(buf, 10, "%d", i - 1);
|
2012-03-12 05:17:08 +02:00
|
|
|
auto it = h.find(buf);
|
|
|
|
if (i < num_valid && it->second != i - 1) exit(-1);
|
2010-06-28 22:01:18 +03:00
|
|
|
}
|
|
|
|
}
|
2010-11-06 01:46:53 +02:00
|
|
|
for (int j = 0; j < 100; ++j) {
|
|
|
|
for (int i = 1000; i > 0; --i) {
|
|
|
|
char buf[10];
|
2012-03-12 05:17:08 +02:00
|
|
|
int key = i*100 - 1;
|
|
|
|
snprintf(buf, 10, "%d", key);
|
|
|
|
auto it = h.find(buf);
|
|
|
|
if (key < num_valid && it->second != key) exit(-1);
|
2010-11-06 01:46:53 +02:00
|
|
|
}
|
|
|
|
}
|
2012-03-15 02:22:40 +02:00
|
|
|
*/
|
2010-06-28 22:01:18 +03:00
|
|
|
}
|