Hashing
Use pair as the key of hashmap/hashset
struct pair_hash {
inline std::size_t operator()(const std::pair<int,int> & v) const {
return v.first*31+v.second;
}
};
std::unordered_set< std::pair<int, int>, pair_hash> mySet;#include <boost/functional/hash.hpp>
std::unordered_set<
pair<int, int>,
boost::hash< std::pair<int, int> >
> mySet;Last updated