[core] Implicit m2::Point hash

Signed-off-by: x7z4w <x7z4w@noreply.codeberg.org>
This commit is contained in:
x7z4w
2025-11-24 17:34:56 +00:00
parent 546383d755
commit ffe07d3337
5 changed files with 24 additions and 11 deletions

View File

@@ -14,11 +14,13 @@
#include <typeinfo>
#include <utility>
#include "3party/skarupke/flat_hash_map.hpp"
// This class tracks usage of drape_ptr's and ref_ptr's
class DpPointerTracker
{
public:
typedef std::map<void *, std::pair<int, std::string>> TAlivePointers;
using TAlivePointers = ska::flat_hash_map<void *, std::pair<int, std::string>>;
static DpPointerTracker & Instance();

View File

@@ -4,6 +4,8 @@
#include "base/math.hpp"
#include "base/matrix.hpp"
#include <boost/container_hash/hash.hpp>
#include <array>
#include <cmath>
#include <limits>
@@ -145,11 +147,6 @@ public:
y = org.y + oldX * dx.y + y * dy.y;
}
/// @}
struct Hash
{
size_t operator()(Point const & p) const { return math::Hash(p.x, p.y); }
};
};
using PointF = Point<float>;
@@ -286,3 +283,15 @@ bool operator<(Point<T> const & l, Point<T> const & r)
return l.y < r.y;
}
} // namespace m2
template <typename T>
struct std::hash<m2::Point<T>>
{
size_t operator()(m2::Point<T> const & p) const
{
size_t seed = 0;
boost::hash_combine(seed, p.x);
boost::hash_combine(seed, p.y);
return seed;
}
};

View File

@@ -139,7 +139,7 @@ protected:
ankerl::unordered_dense::map<uint32_t, vector<string>> m_names;
ankerl::unordered_dense::map<uint32_t, uint8_t> m_ranks;
ankerl::unordered_dense::map<uint32_t, m2::PointD> m_centers;
map<m2::PointD, bool> m_belongsToMatchedRegion;
ska::flat_hash_map<m2::PointD, bool> m_belongsToMatchedRegion;
LocalityScorer m_scorer;
base::MemTrie<UniString, base::VectorValues<uint32_t>> m_searchIndex;