From 71a4b31b5383e1e53713c8618f57b00b3729000c Mon Sep 17 00:00:00 2001 From: Ariel Date: Sat, 3 Feb 2024 00:52:53 +0800 Subject: [PATCH] Update include.hh --- include.hh | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/include.hh b/include.hh index fcb90e3..3fa8bb2 100644 --- a/include.hh +++ b/include.hh @@ -93,6 +93,18 @@ struct safe_hash { } }; +struct pair_hash { + template + size_t operator()(const pair& a) const { + auto hash1 = safe_hash()(a.first); + auto hash2 = safe_hash()(a.second); + if (hash1 != hash2) { + return hash1 ^ hash2; + } + return hash1; + } +}; + /* build data structures */ #define unordered_counter(from, to) __AS_PROCEDURE(unordered_map<__as_typeof(from), size_t, safe_hash> to; for (auto&& x : from) ++to[x];) #define counter(from, to, cmp) __AS_PROCEDURE(map<__as_typeof(from), size_t, cmp> to; for (auto&& x : from) ++to[x];)