Created
February 8, 2021 14:00
-
-
Save giraldeau/ba7422f4b5ac539559b6c17e759889f5 to your computer and use it in GitHub Desktop.
hash function for point with variable dim
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
template<int spacedim> | |
struct PointHashFunc | |
{ | |
std::size_t | |
operator()(const dealii::Point<spacedim>&p) const | |
{ | |
std::size_t h; | |
h = std::hash<double>()(p[0]); | |
if (spacedim > 1) | |
{ | |
std::size_t h2 = std::hash<double>()(p[1]); | |
h = h ^ (h2 << 1); | |
} | |
if (spacedim > 2) | |
{ | |
size_t h3 = std::hash<double>()(p[2]); | |
h = h ^ h3; | |
} | |
if (spacedim > 3) | |
{ | |
AssertThrow(false, ExcNotImplemented()); | |
} | |
return h; | |
} | |
}; // struct PointHashFunc | |
template<int spacedim, typename T> | |
using PointMap = | |
std::unordered_map<dealii::Point<spacedim>, T, PointHashFunc<spacedim> >; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Credits to Jean-Paul Pelteret