2010-06-28 22:01:18 +03:00
|
|
|
#include "cmph_hash_map.h"
|
|
|
|
|
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>
|
|
|
|
|
|
|
|
using std::string;
|
|
|
|
using cxxmph::cmph_hash_map;
|
2010-06-28 22:01:18 +03:00
|
|
|
|
|
|
|
int main(int argc, char** argv) {
|
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-06-28 22:01:18 +03:00
|
|
|
std::cout << it->first << " -> " << it->second << std::endl;
|
|
|
|
}
|
2010-10-29 09:26:37 +03:00
|
|
|
std::cout << "Search -1 gives " << h.find("-1")->second << std::endl;
|
|
|
|
for (int i = 0; i < 1000; ++i) {
|
|
|
|
char buf[10];
|
|
|
|
snprintf(buf, 10, "%d", i);
|
|
|
|
h.insert(std::make_pair(buf, i));
|
|
|
|
}
|
2010-06-28 22:01:18 +03:00
|
|
|
for (int j = 0; j < 1000; ++j) {
|
|
|
|
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);
|
|
|
|
// std::cout << "Search " << i - 1 << " gives " << h.find(i - 1)->second << std::endl;
|
2010-06-28 22:01:18 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|