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

扫码关注我们
微信号:SRE实战
拒绝背锅 运筹帷幄

SRE实战 互联网时代守护先锋,助力企业售后服务体系运筹帷幄!一键直达领取阿里云限量特价优惠。