Skip to content

Instantly share code, notes, and snippets.

@hechen
Created December 14, 2022 04:47
Show Gist options
  • Save hechen/db2c60c413dad45146711da8a5860efd to your computer and use it in GitHub Desktop.
Save hechen/db2c60c413dad45146711da8a5860efd to your computer and use it in GitHub Desktop.
// std::hash<std::vector<int>>
struct VectorHash { template<class T>
std::size_t operator()(vector<T> const &vec) const noexcept {
std::size_t ans = 0;
for (const auto& v: vec) {
ans ^= std::hash<T>{}(n) + (ans << 6) + 0x9e3779b9 + (ans >> 2);
}
return ans;
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment