mirror of
https://codeberg.org/comaps/comaps
synced 2025-12-20 05:13:58 +00:00
[core] Implicit m2::Point hash
Signed-off-by: x7z4w <x7z4w@noreply.codeberg.org>
This commit is contained in:
committed by
Konstantin Pastbin
parent
650f0ca120
commit
eb28c50161
@@ -5,11 +5,12 @@
|
|||||||
|
|
||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
#include <map>
|
|
||||||
#include <optional>
|
#include <optional>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
#include "3party/skarupke/flat_hash_map.hpp"
|
||||||
|
|
||||||
namespace generator
|
namespace generator
|
||||||
{
|
{
|
||||||
namespace cells_merger
|
namespace cells_merger
|
||||||
@@ -67,7 +68,7 @@ private:
|
|||||||
m2::RectD Union(m2::PointI const & startXy);
|
m2::RectD Union(m2::PointI const & startXy);
|
||||||
void Remove(m2::PointI const & minXy, m2::PointI const & maxXy);
|
void Remove(m2::PointI const & minXy, m2::PointI const & maxXy);
|
||||||
|
|
||||||
std::map<m2::PointI, CellWrapper> m_matrix;
|
ska::flat_hash_map<m2::PointI, CellWrapper> m_matrix;
|
||||||
int32_t m_maxX = 0;
|
int32_t m_maxX = 0;
|
||||||
int32_t m_maxY = 0;
|
int32_t m_maxY = 0;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -27,10 +27,11 @@
|
|||||||
|
|
||||||
#include "defines.hpp"
|
#include "defines.hpp"
|
||||||
|
|
||||||
#include <map>
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
#include "3party/skarupke/flat_hash_map.hpp"
|
||||||
|
|
||||||
namespace altitude_test
|
namespace altitude_test
|
||||||
{
|
{
|
||||||
using namespace feature;
|
using namespace feature;
|
||||||
@@ -72,7 +73,7 @@ TPoint3DList const kRoad4 = {{-10, 1, -1}, {-20, 6, -100}, {-20, -11, -110}};
|
|||||||
class MockAltitudeGetter : public AltitudeGetter
|
class MockAltitudeGetter : public AltitudeGetter
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
using TMockAltitudes = std::map<m2::PointI, geometry::Altitude>;
|
using TMockAltitudes = ska::flat_hash_map<m2::PointI, geometry::Altitude>;
|
||||||
|
|
||||||
explicit MockAltitudeGetter(std::vector<TPoint3DList> const & roads)
|
explicit MockAltitudeGetter(std::vector<TPoint3DList> const & roads)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -14,11 +14,13 @@
|
|||||||
#include <typeinfo>
|
#include <typeinfo>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
|
#include "3party/skarupke/flat_hash_map.hpp"
|
||||||
|
|
||||||
// This class tracks usage of drape_ptr's and ref_ptr's
|
// This class tracks usage of drape_ptr's and ref_ptr's
|
||||||
class DpPointerTracker
|
class DpPointerTracker
|
||||||
{
|
{
|
||||||
public:
|
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();
|
static DpPointerTracker & Instance();
|
||||||
|
|
||||||
|
|||||||
@@ -4,6 +4,8 @@
|
|||||||
#include "base/math.hpp"
|
#include "base/math.hpp"
|
||||||
#include "base/matrix.hpp"
|
#include "base/matrix.hpp"
|
||||||
|
|
||||||
|
#include <boost/container_hash/hash.hpp>
|
||||||
|
|
||||||
#include <array>
|
#include <array>
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
#include <limits>
|
#include <limits>
|
||||||
@@ -145,11 +147,6 @@ public:
|
|||||||
y = org.y + oldX * dx.y + y * dy.y;
|
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>;
|
using PointF = Point<float>;
|
||||||
@@ -286,3 +283,15 @@ bool operator<(Point<T> const & l, Point<T> const & r)
|
|||||||
return l.y < r.y;
|
return l.y < r.y;
|
||||||
}
|
}
|
||||||
} // namespace m2
|
} // 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;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|||||||
@@ -139,7 +139,7 @@ protected:
|
|||||||
ankerl::unordered_dense::map<uint32_t, vector<string>> m_names;
|
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, uint8_t> m_ranks;
|
||||||
ankerl::unordered_dense::map<uint32_t, m2::PointD> m_centers;
|
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;
|
LocalityScorer m_scorer;
|
||||||
|
|
||||||
base::MemTrie<UniString, base::VectorValues<uint32_t>> m_searchIndex;
|
base::MemTrie<UniString, base::VectorValues<uint32_t>> m_searchIndex;
|
||||||
|
|||||||
Reference in New Issue
Block a user