diff --git a/Algorithms/BFSComponentExplorer.h b/Algorithms/BFSComponentExplorer.h index 7534b73d5..daab82a14 100644 --- a/Algorithms/BFSComponentExplorer.h +++ b/Algorithms/BFSComponentExplorer.h @@ -12,10 +12,10 @@ template class BFSComponentExplorer { public: - BFSComponentExplorer(const GraphT &dynamicGraph, + BFSComponentExplorer(const GraphT &dynamic_graph, const RestrictionMap &restrictions, const std::unordered_set &barrier_nodes) - : m_graph(dynamicGraph), m_restriction_map(restrictions), m_barrier_nodes(barrier_nodes) + : m_graph(dynamic_graph), m_restriction_map(restrictions), m_barrier_nodes(barrier_nodes) { BOOST_ASSERT(m_graph.GetNumberOfNodes() > 0); } @@ -23,14 +23,14 @@ template class BFSComponentExplorer /*! * Returns the size of the component that the node belongs to. */ - inline unsigned int GetComponentSize(NodeID node) + unsigned int GetComponentSize(const NodeID node) const { BOOST_ASSERT(node < m_component_index_list.size()); return m_component_index_size[m_component_index_list[node]]; } - inline unsigned int GetNumberOfComponents() { return m_component_index_size.size(); } + unsigned int GetNumberOfComponents() { return m_component_index_size.size(); } /*! * Computes the component sizes. @@ -67,7 +67,7 @@ template class BFSComponentExplorer /*! * Explores the current component that starts at node using BFS. */ - inline unsigned ExploreComponent(std::queue> &bfs_queue, + unsigned ExploreComponent(std::queue> &bfs_queue, NodeID node, unsigned current_component) { diff --git a/Algorithms/IteratorBasedCRC32.h b/Algorithms/IteratorBasedCRC32.h index 0c0180f44..a68514dce 100644 --- a/Algorithms/IteratorBasedCRC32.h +++ b/Algorithms/IteratorBasedCRC32.h @@ -129,4 +129,18 @@ class IteratorbasedCRC32 bool use_hardware_implementation; }; +struct RangebasedCRC32 +{ + template + unsigned operator()(const Iteratable &iterable) + { + return crc32(std::begin(iterable), std::end(iterable)); + } + + bool using_hardware() const { return crc32.using_hardware(); } + + private: + IteratorbasedCRC32 crc32; +}; + #endif /* ITERATOR_BASED_CRC32_H */ diff --git a/Contractor/Prepare.cpp b/Contractor/Prepare.cpp index 2982924d3..cea5e2f90 100644 --- a/Contractor/Prepare.cpp +++ b/Contractor/Prepare.cpp @@ -172,7 +172,7 @@ int Prepare::Process(int argc, char *argv[]) BuildRTree(node_based_edge_list); - IteratorbasedCRC32 crc32; + RangebasedCRC32 crc32; if (crc32.using_hardware()) { SimpleLogger().Write() << "using hardware based CRC32 computation"; @@ -182,11 +182,10 @@ int Prepare::Process(int argc, char *argv[]) SimpleLogger().Write() << "using software based CRC32 computation"; } - const unsigned node_based_edge_list_CRC32 = - crc32(node_based_edge_list.begin(), node_based_edge_list.end()); + const unsigned crc32_value = crc32(node_based_edge_list); node_based_edge_list.clear(); node_based_edge_list.shrink_to_fit(); - SimpleLogger().Write() << "CRC32: " << node_based_edge_list_CRC32; + SimpleLogger().Write() << "CRC32: " << crc32_value; WriteNodeMapping(); @@ -264,7 +263,7 @@ int Prepare::Process(int argc, char *argv[]) const unsigned node_array_size = node_array.size(); // serialize crc32, aka checksum - hsgr_output_stream.write((char *)&node_based_edge_list_CRC32, sizeof(unsigned)); + hsgr_output_stream.write((char *)&crc32_value, sizeof(unsigned)); // serialize number of nodes hsgr_output_stream.write((char *)&node_array_size, sizeof(unsigned)); // serialize number of edges