Skip to content

Commit 2f75d6f

Browse files
authored
Merge pull request #6429 from Project-OSRM/less_boost_unordered
Replace boost::unordered_{map/set} with std, also remove code duplication
2 parents 60e2833 + 061f0a1 commit 2f75d6f

File tree

7 files changed

+21
-34
lines changed

7 files changed

+21
-34
lines changed

include/extractor/node_restriction_map.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
#include "util/typedefs.hpp"
77

88
#include <boost/range/adaptor/filtered.hpp>
9-
#include <boost/unordered_map.hpp>
109

10+
#include <unordered_map>
1111
#include <utility>
1212
#include <vector>
1313

include/extractor/restriction_graph.hpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,13 @@
22
#define OSRM_EXTRACTOR_RESTRICTION_GRAPH_HPP_
33

44
#include <boost/assert.hpp>
5-
#include <boost/unordered_map.hpp>
65

76
#include "util/node_based_graph.hpp"
7+
#include "util/std_hash.hpp"
88
#include "util/typedefs.hpp"
99

10+
#include <unordered_map>
11+
1012
namespace osrm
1113
{
1214
namespace extractor
@@ -112,10 +114,10 @@ struct RestrictionGraph
112114
RestrictionRange GetRestrictions(RestrictionID id) const;
113115

114116
// A compressed node-based edge can only have one start node in the restriction graph.
115-
boost::unordered_map<EdgeKey, RestrictionID> start_edge_to_node{};
117+
std::unordered_map<EdgeKey, RestrictionID> start_edge_to_node{};
116118
// A compressed node-based edge can have multiple via nodes in the restriction graph
117119
// (as the compressed edge can appear in paths with different prefixes).
118-
boost::unordered_multimap<EdgeKey, RestrictionID> via_edge_to_node{};
120+
std::unordered_multimap<EdgeKey, RestrictionID> via_edge_to_node{};
119121
std::vector<RestrictionNode> nodes;
120122
// TODO: Investigate reusing DynamicGraph. Currently it requires specific attributes
121123
// (e.g. reversed, weight) that would not make sense for restrictions.

include/extractor/traffic_signals.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
#define OSRM_EXTRACTOR_TRAFFIC_SIGNALS_HPP
33

44
#include "util/typedefs.hpp"
5-
#include <unordered_set>
65

7-
#include <boost/unordered_set.hpp>
6+
#include <boost/functional/hash.hpp>
7+
#include <unordered_set>
88

99
namespace osrm
1010
{

include/extractor/turn_path_compressor.hpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
#include "util/typedefs.hpp"
55

6-
#include <boost/unordered_map.hpp>
6+
#include <unordered_map>
77
#include <vector>
88

99
namespace osrm
@@ -43,9 +43,9 @@ class TurnPathCompressor
4343
// via nodes are the same.
4444
// Similarly, we do not compress the instruction via node in a maneuver override, as we need
4545
// this to identify the location of the maneuver during routing path-processing.
46-
boost::unordered_multimap<NodeID, TurnPath *> starts;
47-
boost::unordered_multimap<NodeID, TurnPath *> vias;
48-
boost::unordered_multimap<NodeID, TurnPath *> ends;
46+
std::unordered_multimap<NodeID, TurnPath *> starts;
47+
std::unordered_multimap<NodeID, TurnPath *> vias;
48+
std::unordered_multimap<NodeID, TurnPath *> ends;
4949
};
5050

5151
} // namespace extractor

include/extractor/way_restriction_map.hpp

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,16 @@
11
#ifndef OSRM_EXTRACTOR_WAY_RESTRICTION_MAP_HPP_
22
#define OSRM_EXTRACTOR_WAY_RESTRICTION_MAP_HPP_
33

4-
#include <utility>
5-
#include <vector>
6-
7-
// to access the turn restrictions
8-
#include <boost/unordered_map.hpp>
9-
104
#include "extractor/restriction.hpp"
115
#include "extractor/restriction_graph.hpp"
126
#include "util/integer_range.hpp"
137
#include "util/typedefs.hpp"
148

9+
// to access the turn restrictions
10+
#include <unordered_map>
11+
#include <utility>
12+
#include <vector>
13+
1514
namespace osrm
1615
{
1716
namespace extractor

src/engine/hint.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@
33
#include "engine/datafacade/datafacade_base.hpp"
44

55
#include <boost/assert.hpp>
6-
#include <boost/unordered_set.hpp>
76

87
#include <algorithm>
98
#include <iterator>
109
#include <tuple>
10+
#include <unordered_set>
1111

1212
namespace osrm
1313
{
@@ -106,8 +106,8 @@ bool Hint::IsValid(const util::Coordinate new_input_coordinates,
106106

107107
// Check hints do not contain duplicate segment pairs
108108
// We can't allow duplicates as search heaps do not support it.
109-
boost::unordered_set<NodeID> forward_segments;
110-
boost::unordered_set<NodeID> reverse_segments;
109+
std::unordered_set<NodeID> forward_segments;
110+
std::unordered_set<NodeID> reverse_segments;
111111
for (const auto &seg_hint : segment_hints)
112112
{
113113
const auto forward_res = forward_segments.insert(seg_hint.phantom.forward_segment_id.id);

src/extractor/edge_based_graph_factory.cpp

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -34,20 +34,6 @@
3434
#include <tbb/parallel_for.h>
3535
#include <tbb/parallel_pipeline.h>
3636

37-
namespace std
38-
{
39-
template <> struct hash<std::pair<NodeID, NodeID>>
40-
{
41-
std::size_t operator()(const std::pair<NodeID, NodeID> &mk) const noexcept
42-
{
43-
std::size_t seed = 0;
44-
boost::hash_combine(seed, mk.first);
45-
boost::hash_combine(seed, mk.second);
46-
return seed;
47-
}
48-
};
49-
} // namespace std
50-
5137
namespace osrm
5238
{
5339
namespace extractor
@@ -1283,7 +1269,7 @@ void EdgeBasedGraphFactory::GenerateEdgeExpandedEdges(
12831269
std::vector<ConditionalTurnPenalty>
12841270
EdgeBasedGraphFactory::IndexConditionals(std::vector<Conditional> &&conditionals) const
12851271
{
1286-
boost::unordered_multimap<std::pair<NodeID, NodeID>, ConditionalTurnPenalty *> index;
1272+
std::unordered_multimap<std::pair<NodeID, NodeID>, ConditionalTurnPenalty *> index;
12871273

12881274
// build and index of all conditional restrictions
12891275
for (auto &conditional : conditionals)

0 commit comments

Comments
 (0)