#include <iostream>
struct HashFunctor
{
size_t operator () (int key) const
{
return (size_t)(key * 2654435761u);
}
};
struct CompareLess
{
bool operator () (const int& a, const int& b) const
{ return a < b; }
};
int main()
{
#define SUB_BLOCK_SIZE 8192
#define SUB_BLOCKS_PER_BLOCK 256
int, char, HashFunctor, CompareLess, SUB_BLOCK_SIZE, SUB_BLOCKS_PER_BLOCK
> unordered_map_type;
unordered_map_type my_map;
my_map.
insert(std::make_pair(1,
'a'));
my_map.insert(std::make_pair(2, 'b'));
my_map.insert(std::make_pair(3, 'c'));
my_map.insert(std::make_pair(4, 'd'));
my_map.erase(3);
unordered_map_type::iterator iter;
std::cout << "my_map contains:\n";
for (iter = my_map.begin(); iter != my_map.end(); ++iter)
{
std::cout << iter->first << " => " << iter->second << std::endl;
}
std::cout << "my_map[2] = " << my_map[2] << std::endl;
std::vector<unordered_map_type::value_type> value_array;
for (int i = 0; i < 128; ++i)
value_array.push_back(std::make_pair(i, (char)i));
my_map.insert(value_array.begin(), value_array.end(), 8 * 1024 * 1024);
std::cout << "my_map[42] = " << my_map[42] << std::endl;
std::cout << "my_map.size() = " << my_map.size() << std::endl;
return 0;
}