struct Map_key {
Double first;
Double second;
Double third;
Double forth;
};
struct Keyhash
{
std::size_t operator () (const Map_key & k) const
{
Using Boost::hash_value;
Using Boost::hash_combine;
std::size_t seed = 0;
Hash_combine (Seed,hash_value (K.first));
Hash_combine (Seed,hash_value (K.second));
Hash_combine (Seed,hash_value (K.third));
Hash_combine (Seed,hash_value (K.forth));
return seed;
}
};
struct Cmp_fun//comparison function = =
{
BOOL Operator () (Map_key addr1, Map_key addr2) const {
Return ((Addr1.first==addr2.first) && (Addr1.second==addr2.second) && (Addr1.third==addr2.third) && (Addr1.forth==addr2.forth));
}
};
Static Std::tr1::unordered_map<map_key, double,keyhash,cmp_fun> map_dist;
Originally wanted to convert four double to char*, found to be a bug, wrote a structure, and then the same situation can be handled.
Unordered_map Custom Key