Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Zolotarev <alex@maps.me>2015-06-24 15:47:00 +0300
committerAlex Zolotarev <alex@maps.me>2015-09-23 02:52:33 +0300
commita2bbe7a4e180b996e73e183d53bc05f22618fa21 (patch)
tree3806d15f3450d9bfc8425991d17f5061bbc29c58
parentd8eebb597792cc47564bb18d188be35232260506 (diff)
boost::hash -> std::hash
TODO: Should we improve current hash implementation/review do we really need unordered sets/maps?
-rw-r--r--base/math.hpp9
-rw-r--r--generator/tesselator.cpp2
-rw-r--r--generator/tesselator.hpp14
-rw-r--r--geometry/point2d.hpp24
-rw-r--r--routing/cross_mwm_road_graph.hpp4
-rw-r--r--search/feature_offset_match.hpp2
-rw-r--r--std/functional.hpp2
7 files changed, 35 insertions, 22 deletions
diff --git a/base/math.hpp b/base/math.hpp
index 1015825082..a508dcb102 100644
--- a/base/math.hpp
+++ b/base/math.hpp
@@ -1,10 +1,11 @@
#pragma once
#include "base/assert.hpp"
+#include "std/algorithm.hpp"
#include "std/cmath.hpp"
+#include "std/functional.hpp"
#include "std/limits.hpp"
#include "std/type_traits.hpp"
-#include "std/algorithm.hpp"
#include <boost/integer.hpp>
@@ -207,4 +208,10 @@ template <typename T> T GCD(T a, T b)
return multiplier * gcd;
}
+template <typename T1, typename T2>
+size_t Hash(T1 t1, T2 t2)
+{
+ return (hash<T1>()(t1) ^ (hash<T2>()(t2) << 1));
+}
+
}
diff --git a/generator/tesselator.cpp b/generator/tesselator.cpp
index 1c650dc9c2..7d6f4bbe2a 100644
--- a/generator/tesselator.cpp
+++ b/generator/tesselator.cpp
@@ -80,7 +80,7 @@ namespace tesselator
void TrianglesInfo::ListInfo::AddNeighbour(int p1, int p2, int trg)
{
// find or insert element for key
- pair<neighbors_t::iterator, bool> ret = m_neighbors.insert(make_pair(make_pair(p1, p2), trg));
+ pair<TNeighbours::iterator, bool> ret = m_neighbors.insert(make_pair(make_pair(p1, p2), trg));
// triangles should not duplicate
CHECK ( ret.second, ("Duplicating triangles for indices : ", p1, p2) );
diff --git a/generator/tesselator.hpp b/generator/tesselator.hpp
index 59d8603246..43fcfeafde 100644
--- a/generator/tesselator.hpp
+++ b/generator/tesselator.hpp
@@ -64,8 +64,16 @@ namespace tesselator
mutable vector<bool> m_visited;
// directed edge -> triangle
- typedef unordered_map<pair<int, int>, int> neighbors_t;
- neighbors_t m_neighbors;
+ template <typename T1, typename T2> struct HashPair
+ {
+ size_t operator()(pair<T1, T2> const & p) const
+ {
+ return my::Hash(p.first, p.second);
+ }
+ };
+
+ typedef unordered_map<pair<int, int>, int, HashPair<int, int>> TNeighbours;
+ TNeighbours m_neighbors;
void AddNeighbour(int p1, int p2, int trg);
@@ -76,7 +84,7 @@ namespace tesselator
PointsInfo const & points, Triangle const & from, Triangle const & to) const;
public:
- typedef neighbors_t::const_iterator iter_t;
+ typedef TNeighbours::const_iterator iter_t;
ListInfo(size_t count)
{
diff --git a/geometry/point2d.hpp b/geometry/point2d.hpp
index d4e61f2620..46d394f7ea 100644
--- a/geometry/point2d.hpp
+++ b/geometry/point2d.hpp
@@ -7,9 +7,10 @@
#include "std/array.hpp"
#include "std/cmath.hpp"
+#include "std/functional.hpp"
#include "std/sstream.hpp"
#include "std/typeinfo.hpp"
-#include "std/unordered_map.hpp"
+
namespace m2
{
@@ -178,6 +179,14 @@ namespace m2
x = org.x + oldX * dx.x + y * dy.x;
y = org.y + oldX * dx.y + y * dy.y;
}
+
+ struct Hash
+ {
+ size_t operator()(m2::Point<T> const & p) const
+ {
+ return my::Hash(p.x, p.y);
+ }
+ };
};
template <typename T>
@@ -392,16 +401,3 @@ bool AlmostEqualULPs(m2::Point<T> const & p1, m2::Point<T> const & p2, unsigned
}
}
-
-// hash function for unordered map realisation.
-namespace boost
-{
-template <>
-struct hash<m2::PointD>
-{
- size_t operator()(m2::PointD const & p) const
- {
- return (hash<double>()(p.x) ^ (hash<double>()(p.y) >> 1));
- }
-};
-}
diff --git a/routing/cross_mwm_road_graph.hpp b/routing/cross_mwm_road_graph.hpp
index 65e8ca5902..882a52e16c 100644
--- a/routing/cross_mwm_road_graph.hpp
+++ b/routing/cross_mwm_road_graph.hpp
@@ -111,6 +111,8 @@ private:
map<CrossNode, vector<CrossWeightedEdge> > m_virtualEdges;
mutable RoutingIndexManager m_indexManager;
- mutable unordered_map<m2::PointD, BorderCross> m_cachedNextNodes;
+
+ // hash function for unordered map realisation.
+ mutable unordered_map<m2::PointD, BorderCross, m2::PointD::Hash> m_cachedNextNodes;
};
} // namespace routing
diff --git a/search/feature_offset_match.hpp b/search/feature_offset_match.hpp
index 69748356b1..acbcebc6de 100644
--- a/search/feature_offset_match.hpp
+++ b/search/feature_offset_match.hpp
@@ -178,7 +178,7 @@ template <class FilterT> class OffsetIntersecter
{
size_t operator() (ValueT const & v) const
{
- return (boost::hash_value(v.m_featureId));
+ return static_cast<size_t>(v.m_featureId);
}
};
struct EqualFn
diff --git a/std/functional.hpp b/std/functional.hpp
index cc34502864..c1d5953d80 100644
--- a/std/functional.hpp
+++ b/std/functional.hpp
@@ -6,10 +6,10 @@
#endif
#include <functional>
-
using std::less;
using std::greater;
using std::equal_to;
+using std::hash;
#ifdef DEBUG_NEW
#define new DEBUG_NEW