struct pair_hash
{
template<class T1, class T2>
std::size_t operator() (const std::pair<T1, T2>& p) const
{
auto h1 = std::hash<T1>{}(p.first);
auto h2 = std::hash<T2>{}(p.second);
return h1 ^ h2;
}
};
unordered_map<pair<int, bool>, int, pair_hash> Map;
今天为了写leetcode 的每日一题《391. 完美矩形》,想到需要使用hash存储矩形内部的点,需要使用到pair和unordered_map,就查询了一下,在此记录。