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,就自己写了个结构体,之后相同的情况可以如此处理。
时间: 2024-10-13 14:33:46