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 //比較函數 ==
{
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;
原本想把四個double轉換成char*,發現是個bug,就本身寫了個結構體,以後相同的狀況能夠如此處理。函數