using namespace std;
class PixID{
public:
int _r;
int _c;
PixID(){}
PixID(int r, int c){
_r = r;
_c = c;
}
// bool operator==(const PixID & p) const
// {
// return _r == p._r && _c == p._c;
// }
};
// inline size_t PixID_hash( const PixID & p )
// {
// return std::hash<int>()(p._r) ^ std::hash<int>()(p._c);
// }
namespace std{
template<>
struct hash<PixID>{//哈希的模板定制
public:
size_t operator()(const PixID &p) const
{
return hash<int>()(p._r) ^ hash<int>()(p._c);
}
};
template<>
struct equal_to<PixID>{//等比的模板定制
public:
bool operator()(const PixID &p1, const PixID &p2) const
{
return p1._r == p2._r && p1._c == p2._c;
}
};
}
参考链接: https://blog.csdn.net/y109y/article/details/82669620