mirror of
https://codeberg.org/comaps/comaps
synced 2026-01-07 13:03:54 +00:00
[core] Implicit m2::Point hash
Signed-off-by: x7z4w <x7z4w@noreply.codeberg.org>
This commit is contained in:
@@ -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;
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user