From 7b73b977ffa7b7cd349f2fa2cfd1d06b0523a2cd Mon Sep 17 00:00:00 2001 From: Dennis Luxen Date: Sat, 29 Oct 2022 22:57:14 +0200 Subject: [PATCH] Replace boost::unordered_{map/set} with std, also remove code duplication --- include/extractor/node_restriction_map.hpp | 2 +- include/extractor/restriction_graph.hpp | 8 +++++--- include/extractor/traffic_signals.hpp | 2 -- include/extractor/turn_path_compressor.hpp | 8 ++++---- include/extractor/way_restriction_map.hpp | 10 +++++----- src/engine/hint.cpp | 6 +++--- src/extractor/edge_based_graph_factory.cpp | 16 +--------------- 7 files changed, 19 insertions(+), 33 deletions(-) diff --git a/include/extractor/node_restriction_map.hpp b/include/extractor/node_restriction_map.hpp index f2c9f049c..fe7e89673 100644 --- a/include/extractor/node_restriction_map.hpp +++ b/include/extractor/node_restriction_map.hpp @@ -6,8 +6,8 @@ #include "util/typedefs.hpp" #include -#include +#include #include #include diff --git a/include/extractor/restriction_graph.hpp b/include/extractor/restriction_graph.hpp index 9b7d4eefe..15932720c 100644 --- a/include/extractor/restriction_graph.hpp +++ b/include/extractor/restriction_graph.hpp @@ -2,11 +2,13 @@ #define OSRM_EXTRACTOR_RESTRICTION_GRAPH_HPP_ #include -#include #include "util/node_based_graph.hpp" +#include "util/std_hash.hpp" #include "util/typedefs.hpp" +#include + namespace osrm { namespace extractor @@ -112,10 +114,10 @@ struct RestrictionGraph RestrictionRange GetRestrictions(RestrictionID id) const; // A compressed node-based edge can only have one start node in the restriction graph. - boost::unordered_map start_edge_to_node{}; + std::unordered_map start_edge_to_node{}; // A compressed node-based edge can have multiple via nodes in the restriction graph // (as the compressed edge can appear in paths with different prefixes). - boost::unordered_multimap via_edge_to_node{}; + std::unordered_multimap via_edge_to_node{}; std::vector nodes; // TODO: Investigate reusing DynamicGraph. Currently it requires specific attributes // (e.g. reversed, weight) that would not make sense for restrictions. diff --git a/include/extractor/traffic_signals.hpp b/include/extractor/traffic_signals.hpp index 36913092c..110346dbf 100644 --- a/include/extractor/traffic_signals.hpp +++ b/include/extractor/traffic_signals.hpp @@ -4,8 +4,6 @@ #include "util/typedefs.hpp" #include -#include - namespace osrm { namespace extractor diff --git a/include/extractor/turn_path_compressor.hpp b/include/extractor/turn_path_compressor.hpp index d99130235..8f19ea6fa 100644 --- a/include/extractor/turn_path_compressor.hpp +++ b/include/extractor/turn_path_compressor.hpp @@ -3,7 +3,7 @@ #include "util/typedefs.hpp" -#include +#include #include namespace osrm @@ -43,9 +43,9 @@ class TurnPathCompressor // via nodes are the same. // Similarly, we do not compress the instruction via node in a maneuver override, as we need // this to identify the location of the maneuver during routing path-processing. - boost::unordered_multimap starts; - boost::unordered_multimap vias; - boost::unordered_multimap ends; + std::unordered_multimap starts; + std::unordered_multimap vias; + std::unordered_multimap ends; }; } // namespace extractor diff --git a/include/extractor/way_restriction_map.hpp b/include/extractor/way_restriction_map.hpp index da29aff67..1e079da4f 100644 --- a/include/extractor/way_restriction_map.hpp +++ b/include/extractor/way_restriction_map.hpp @@ -1,17 +1,17 @@ #ifndef OSRM_EXTRACTOR_WAY_RESTRICTION_MAP_HPP_ #define OSRM_EXTRACTOR_WAY_RESTRICTION_MAP_HPP_ -#include -#include - -// to access the turn restrictions -#include #include "extractor/restriction.hpp" #include "extractor/restriction_graph.hpp" #include "util/integer_range.hpp" #include "util/typedefs.hpp" +// to access the turn restrictions +#include +#include +#include + namespace osrm { namespace extractor diff --git a/src/engine/hint.cpp b/src/engine/hint.cpp index f7cad73a1..64d05783f 100644 --- a/src/engine/hint.cpp +++ b/src/engine/hint.cpp @@ -3,10 +3,10 @@ #include "engine/datafacade/datafacade_base.hpp" #include -#include #include #include +#include #include namespace osrm @@ -106,8 +106,8 @@ bool Hint::IsValid(const util::Coordinate new_input_coordinates, // Check hints do not contain duplicate segment pairs // We can't allow duplicates as search heaps do not support it. - boost::unordered_set forward_segments; - boost::unordered_set reverse_segments; + std::unordered_set forward_segments; + std::unordered_set reverse_segments; for (const auto &seg_hint : segment_hints) { const auto forward_res = forward_segments.insert(seg_hint.phantom.forward_segment_id.id); diff --git a/src/extractor/edge_based_graph_factory.cpp b/src/extractor/edge_based_graph_factory.cpp index 30650b4a4..547fece7c 100644 --- a/src/extractor/edge_based_graph_factory.cpp +++ b/src/extractor/edge_based_graph_factory.cpp @@ -34,20 +34,6 @@ #include #include -namespace std -{ -template <> struct hash> -{ - std::size_t operator()(const std::pair &mk) const noexcept - { - std::size_t seed = 0; - boost::hash_combine(seed, mk.first); - boost::hash_combine(seed, mk.second); - return seed; - } -}; -} // namespace std - namespace osrm { namespace extractor @@ -1283,7 +1269,7 @@ void EdgeBasedGraphFactory::GenerateEdgeExpandedEdges( std::vector EdgeBasedGraphFactory::IndexConditionals(std::vector &&conditionals) const { - boost::unordered_multimap, ConditionalTurnPenalty *> index; + std::unordered_multimap, ConditionalTurnPenalty *> index; // build and index of all conditional restrictions for (auto &conditional : conditionals)