1
Fork 0
turbonss/cxxmph/cmph_hash_map_test.cc

52 lines
1.3 KiB
C++
Raw Normal View History

2010-06-28 22:01:18 +03:00
#include "cmph_hash_map.h"
#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>
2010-11-08 22:19:44 +02:00
using std::make_pair;
2010-10-29 09:26:37 +03:00
using std::string;
using cxxmph::cmph_hash_map;
2010-06-28 22:01:18 +03:00
int main(int argc, char** argv) {
2010-11-08 22:19:44 +02:00
cmph_hash_map<int64_t, int64_t> b;
2010-11-09 07:51:33 +02:00
for (int i = 0; i < 2*1000*1000; ++i) {
2010-11-08 22:19:44 +02:00
b.insert(make_pair(i, i));
}
2011-01-21 03:07:46 +02:00
for (int i = 0; i < 100*1000*1000; ++i) {
b.find(i);
}
2010-11-08 22:19:44 +02:00
/*
2010-10-29 09:26:37 +03:00
cmph_hash_map<string, int> h;
h.insert(std::make_pair("-1",-1));
cmph_hash_map<string, int>::const_iterator it;
for (it = h.begin(); it != h.end(); ++it) {
2010-11-05 04:17:08 +02:00
std::cerr << it->first << " -> " << it->second << std::endl;
2010-06-28 22:01:18 +03:00
}
2010-11-05 04:17:08 +02:00
std::cerr << "Search -1 gives " << h.find("-1")->second << std::endl;
for (int i = 0; i < 100; ++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);
h.find(buf);
2010-11-05 04:17:08 +02:00
std::cerr << "Search " << i - 1 << " gives " << h.find(buf)->second << std::endl;
2010-06-28 22:01:18 +03:00
}
}
for (int j = 0; j < 100; ++j) {
for (int i = 1000; i > 0; --i) {
char buf[10];
snprintf(buf, 10, "%d", i*100 - 1);
h.find(buf);
std::cerr << "Search " << i*100 - 1 << " gives " << h.find(buf)->second << std::endl;
}
}
2010-11-08 22:19:44 +02:00
*/
2010-06-28 22:01:18 +03:00
}