Pixiv - Miracle
13-哈希
137 字
1 分钟
13-哈希
哈希
#include <bits/stdc++.h>using namespace std;using ull = unsigned long long;using ll = long long;
namespace hash_util {inline void hash_combine(ull& seed, ull value) { seed ^= value + 0x9e3779b9 + (seed << 6) + (seed >> 2);}
template <class T>inline void hash_combine(ull& seed, const T& value) { hash_combine(seed, hash<T>{}(value));}pair哈希
struct pair_hash { template <class T1, class T2> ull operator()(const pair<T1, T2>& p) const { ull seed = 0; hash_combine(seed, p.first); hash_combine(seed, p.second); return seed; }};tuple哈希
struct tuple_hash { template <class... Ts> ull operator()(const tuple<Ts...>& t) const { ull seed = 0; apply([&seed](const auto&... args) { (hash_combine(seed, args), ...); }, t); return seed; }};}文章分享
如果这篇文章对你有帮助,欢迎分享给更多人!
随机文章 随机推荐