From 9710f39cad073003af535cda247fafbac95329de Mon Sep 17 00:00:00 2001 From: Dennis Luxen Date: Wed, 7 May 2014 16:17:47 +0200 Subject: [PATCH] remove (almost) all BOOST_FOREACH calls --- Contractor/Contractor.h | 13 +++++++------ Contractor/GeometryCompressor.cpp | 5 ++--- Extractor/BaseParser.cpp | 5 ++--- Extractor/ExtractionContainers.cpp | 7 +++---- Extractor/PBFParser.cpp | 5 ++--- RoutingAlgorithms/AlternativePathRouting.h | 12 ++++++------ RoutingAlgorithms/BasicRoutingInterface.h | 1 - RoutingAlgorithms/ShortestPathRouting.h | 12 ++++-------- Server/Connection.cpp | 2 +- Server/Http/Reply.cpp | 10 ++++------ Server/RequestHandler.cpp | 2 -- prepare.cpp | 3 +-- 12 files changed, 32 insertions(+), 45 deletions(-) diff --git a/Contractor/Contractor.h b/Contractor/Contractor.h index 55d54c83b..5d103f8a9 100644 --- a/Contractor/Contractor.h +++ b/Contractor/Contractor.h @@ -40,7 +40,6 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "../Util/StringUtil.h" #include -#include #include #include #include @@ -263,7 +262,7 @@ public: std::cout << " [flush " << numberOfContractedNodes << " nodes] " << std::flush; //Delete old heap data to free memory that we need for the coming operations - BOOST_FOREACH(_ThreadData * data, threadData) { + for(_ThreadData * data : threadData) { delete data; } threadData.clear(); @@ -380,7 +379,7 @@ public: //insert new edges for ( unsigned threadNum = 0; threadNum < maxThreads; ++threadNum ) { _ThreadData& data = *threadData[threadNum]; - BOOST_FOREACH(const _ContractorEdge& edge, data.insertedEdges) { + for(const _ContractorEdge& edge : data.insertedEdges) { _DynamicGraph::EdgeIterator currentEdgeID = _graph->FindEdge(edge.source, edge.target); if(currentEdgeID < _graph->EndEdges(edge.source) ) { _DynamicGraph::EdgeData & currentEdgeData = _graph->GetEdgeData(currentEdgeID); @@ -436,7 +435,7 @@ public: p.printStatus(numberOfContractedNodes); } - BOOST_FOREACH(_ThreadData * data, threadData) { + for(_ThreadData * data : threadData) { delete data; } threadData.clear(); @@ -711,7 +710,7 @@ private: std::sort( neighbours.begin(), neighbours.end() ); neighbours.resize( std::unique( neighbours.begin(), neighbours.end() ) - neighbours.begin() ); - BOOST_FOREACH(const NodeID u, neighbours) { + for(const NodeID u : neighbours) { priorities[u] = _Evaluate( data, &( nodeData )[u], u ); } return true; @@ -744,11 +743,13 @@ private: neighbours.resize( std::unique( neighbours.begin(), neighbours.end() ) - neighbours.begin() ); //examine all neighbours that are at most 2 hops away - BOOST_FOREACH(const NodeID u, neighbours) { + for(const NodeID u : neighbours) { for ( _DynamicGraph::EdgeIterator e = _graph->BeginEdges( u ) ; e < _graph->EndEdges( u ) ; ++e ) { const NodeID target = _graph->GetTarget( e ); if(node==target) + { continue; + } const double targetPriority = priorities[target]; assert( targetPriority >= 0 ); diff --git a/Contractor/GeometryCompressor.cpp b/Contractor/GeometryCompressor.cpp index f7574ab15..4d85e01ff 100644 --- a/Contractor/GeometryCompressor.cpp +++ b/Contractor/GeometryCompressor.cpp @@ -31,7 +31,6 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include #include #include -#include #include @@ -101,7 +100,7 @@ void GeometryCompressor::SerializeInternalVector(const std::string &path) const const unsigned unpacked_size = current_vector.size(); control_sum += unpacked_size; BOOST_ASSERT(UINT_MAX != unpacked_size); - BOOST_FOREACH (const CompressedNode current_node, current_vector) + for (const CompressedNode current_node : current_vector) { geometry_out_stream.write((char *)&(current_node.first), sizeof(NodeID)); } @@ -200,7 +199,7 @@ void GeometryCompressor::PrintStatistics() const uint64_t number_of_compressed_geometries = 0; uint64_t longest_chain_length = 0; - BOOST_FOREACH (const std::vector ¤t_vector, m_compressed_geometries) + for (const std::vector ¤t_vector : m_compressed_geometries) { number_of_compressed_geometries += current_vector.size(); longest_chain_length = std::max(longest_chain_length, (uint64_t)current_vector.size()); diff --git a/Extractor/BaseParser.cpp b/Extractor/BaseParser.cpp index 23464e413..01d119766 100644 --- a/Extractor/BaseParser.cpp +++ b/Extractor/BaseParser.cpp @@ -36,7 +36,6 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include #include -#include #include BaseParser::BaseParser( @@ -76,7 +75,7 @@ void BaseParser::ReadRestrictionExceptions() { const unsigned exception_count = restriction_exceptions.size(); SimpleLogger().Write() << "Found " << exception_count << " exceptions to turn restrictions:"; - BOOST_FOREACH(const std::string & str, restriction_exceptions) { + for(const std::string & str : restriction_exceptions) { SimpleLogger().Write() << " " << str; } } else { @@ -124,7 +123,7 @@ bool BaseParser::ShouldIgnoreRestriction( //only a few exceptions are actually defined. std::vector exceptions; boost::algorithm::split_regex(exceptions, except_tag_string, boost::regex("[;][ ]*")); - BOOST_FOREACH(std::string& current_string, exceptions) { + for (std::string& current_string : exceptions) { std::vector::const_iterator string_iterator; string_iterator = std::find( restriction_exceptions.begin(), diff --git a/Extractor/ExtractionContainers.cpp b/Extractor/ExtractionContainers.cpp index d2c75abc2..a600f6416 100644 --- a/Extractor/ExtractionContainers.cpp +++ b/Extractor/ExtractionContainers.cpp @@ -31,7 +31,6 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "../Util/SimpleLogger.h" #include -#include #include #include @@ -461,7 +460,7 @@ void ExtractionContainers::PrepareData( //compute total number of chars unsigned total_number_of_chars = 0; - BOOST_FOREACH(const std::string & temp_string, name_list) { + for (const std::string & temp_string : name_list) { total_number_of_chars += temp_string.length(); } //write total number of chars @@ -471,7 +470,7 @@ void ExtractionContainers::PrepareData( ); //write prefixe sums unsigned name_lengths_prefix_sum = 0; - BOOST_FOREACH(const std::string & temp_string, name_list) { + for (const std::string & temp_string : name_list) { name_file_stream.write( (char *)&(name_lengths_prefix_sum), sizeof(unsigned) @@ -485,7 +484,7 @@ void ExtractionContainers::PrepareData( ); //write all chars consecutively - BOOST_FOREACH(const std::string & temp_string, name_list) { + for (const std::string & temp_string : name_list) { const unsigned string_length = temp_string.length(); name_file_stream.write(temp_string.c_str(), string_length); } diff --git a/Extractor/PBFParser.cpp b/Extractor/PBFParser.cpp index 47a366c9f..34dba6630 100644 --- a/Extractor/PBFParser.cpp +++ b/Extractor/PBFParser.cpp @@ -42,7 +42,6 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include -#include #include #include @@ -226,7 +225,7 @@ inline void PBFParser::parseDenseNode(_ThreadData * threadData) { } } - BOOST_FOREACH(const ImportNode &import_node, extracted_nodes_vector) + for(const ImportNode &import_node : extracted_nodes_vector) { extractor_callbacks->nodeFunction(import_node); } @@ -365,7 +364,7 @@ inline void PBFParser::parseWay(_ThreadData * threadData) { } } - BOOST_FOREACH(ExtractionWay & extraction_way, parsed_way_vector) + for(ExtractionWay & extraction_way : parsed_way_vector) { if (2 <= extraction_way.path.size()) { diff --git a/RoutingAlgorithms/AlternativePathRouting.h b/RoutingAlgorithms/AlternativePathRouting.h index 27c50f1cd..ef9c89604 100644 --- a/RoutingAlgorithms/AlternativePathRouting.h +++ b/RoutingAlgorithms/AlternativePathRouting.h @@ -32,7 +32,6 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "../DataStructures/SearchEngineData.h" #include -#include #include #include @@ -199,7 +198,7 @@ public: unsigned index_into_forward_path = 0; //sweep over search space, compute forward sharing for each current edge (u,v) - BOOST_FOREACH(const SearchSpaceEdge & current_edge, forward_search_space) { + for(const SearchSpaceEdge & current_edge : forward_search_space) { const NodeID u = current_edge.first; const NodeID v = current_edge.second; if( @@ -217,7 +216,7 @@ public: unsigned index_into_reverse_path = 0; //sweep over search space, compute backward sharing - BOOST_FOREACH(const SearchSpaceEdge & current_edge, reverse_search_space) { + for (const SearchSpaceEdge & current_edge : reverse_search_space) { const NodeID u = current_edge.first; const NodeID v = current_edge.second; if( @@ -239,7 +238,8 @@ public: // SimpleLogger().Write(logDEBUG) << "rev_search_space size: " << reverse_search_space.size() << ", marked " << approximated_reverse_sharing.size() << " nodes"; std::vector preselected_node_list; - BOOST_FOREACH(const NodeID node, via_node_candidate_list) { + for (const NodeID node : via_node_candidate_list) + { boost::unordered_map::const_iterator fwd_iterator = approximated_forward_sharing.find(node); const int fwd_sharing = (fwd_iterator != approximated_forward_sharing.end()) ? fwd_iterator->second : 0; boost::unordered_map::const_iterator rev_iterator = approximated_reverse_sharing.find(node); @@ -269,7 +269,7 @@ public: std::vector ranked_candidates_list; //prioritizing via nodes for deep inspection - BOOST_FOREACH(const NodeID node, preselected_node_list) { + for (const NodeID node : preselected_node_list) { int length_of_via_path = 0, sharing_of_via_path = 0; ComputeLengthAndSharingOfViaPath(node, &length_of_via_path, &sharing_of_via_path, packed_shortest_path); const int maximum_allowed_sharing = upper_bound_to_shortest_path_distance*VIAPATH_GAMMA; @@ -291,7 +291,7 @@ public: NodeID selected_via_node = SPECIAL_NODEID; int length_of_via_path = INVALID_EDGE_WEIGHT; NodeID s_v_middle = SPECIAL_NODEID, v_t_middle = SPECIAL_NODEID; - BOOST_FOREACH(const RankedCandidateNode & candidate, ranked_candidates_list){ + for (const RankedCandidateNode & candidate : ranked_candidates_list){ if(ViaNodeCandidatePassesTTest(forward_heap1, reverse_heap1, forward_heap2, reverse_heap2, candidate, upper_bound_to_shortest_path_distance, &length_of_via_path, &s_v_middle, &v_t_middle)) { // select first admissable selected_via_node = candidate.node; diff --git a/RoutingAlgorithms/BasicRoutingInterface.h b/RoutingAlgorithms/BasicRoutingInterface.h index e26b504cb..08801606f 100644 --- a/RoutingAlgorithms/BasicRoutingInterface.h +++ b/RoutingAlgorithms/BasicRoutingInterface.h @@ -35,7 +35,6 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "../Util/SimpleLogger.h" #include -#include #include #include diff --git a/RoutingAlgorithms/ShortestPathRouting.h b/RoutingAlgorithms/ShortestPathRouting.h index 45dffc411..9868d2a75 100644 --- a/RoutingAlgorithms/ShortestPathRouting.h +++ b/RoutingAlgorithms/ShortestPathRouting.h @@ -29,7 +29,6 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #define SHORTESTPATHROUTING_H_ #include -#include #include "BasicRoutingInterface.h" #include "../DataStructures/SearchEngineData.h" @@ -57,10 +56,8 @@ public: RawRouteData & raw_route_data ) const { - BOOST_FOREACH( - const PhantomNodes & phantom_node_pair, - phantom_nodes_vector - ){ + for (const PhantomNodes & phantom_node_pair : phantom_nodes_vector) + { if( phantom_node_pair.AtLeastOnePhantomNodeIsInvalid() ) { // raw_route_data.lengthOfShortestPath = INT_MAX; // raw_route_data.lengthOfAlternativePath = INT_MAX; @@ -93,9 +90,8 @@ public: int current_leg = 0; //Get distance to next pair of target nodes. - BOOST_FOREACH( - const PhantomNodes & phantom_node_pair, phantom_nodes_vector - ){ + for(const PhantomNodes & phantom_node_pair : phantom_nodes_vector) + { forward_heap1.Clear(); forward_heap2.Clear(); reverse_heap1.Clear(); reverse_heap2.Clear(); int local_upper_bound1 = INT_MAX; diff --git a/Server/Connection.cpp b/Server/Connection.cpp index 227852364..c010d980c 100644 --- a/Server/Connection.cpp +++ b/Server/Connection.cpp @@ -231,7 +231,7 @@ void Connection::compressBufferCollection( boost::iostreams::back_inserter(compressed_data) ); - BOOST_FOREACH( const std::string & line, uncompressed_data) { + for ( const std::string & line : uncompressed_data) { compressing_stream << line; } diff --git a/Server/Http/Reply.cpp b/Server/Http/Reply.cpp index e96098da1..7ff1575e4 100644 --- a/Server/Http/Reply.cpp +++ b/Server/Http/Reply.cpp @@ -25,8 +25,6 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include - #include #include "../../Util/StringUtil.h" @@ -34,7 +32,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. namespace http { void Reply::setSize(const unsigned size) { - BOOST_FOREACH ( Header& h, headers) { + for ( Header& h : headers) { if("Content-Length" == h.name) { intToString(size,h.value); } @@ -45,7 +43,7 @@ void Reply::setSize(const unsigned size) { void Reply::SetUncompressedSize() { unsigned uncompressed_size = 0; - BOOST_FOREACH ( const std::string & current_line, content) + for ( const std::string & current_line : content) { uncompressed_size += current_line.size(); } @@ -56,14 +54,14 @@ void Reply::SetUncompressedSize() std::vector Reply::toBuffers(){ std::vector buffers; buffers.push_back(ToBuffer(status)); - BOOST_FOREACH(const Header & h, headers) { + for (const Header & h : headers) { buffers.push_back(boost::asio::buffer(h.name)); buffers.push_back(boost::asio::buffer(seperators)); buffers.push_back(boost::asio::buffer(h.value)); buffers.push_back(boost::asio::buffer(crlf)); } buffers.push_back(boost::asio::buffer(crlf)); - BOOST_FOREACH(const std::string & line, content) { + for (const std::string & line : content) { buffers.push_back(boost::asio::buffer(line)); } return buffers; diff --git a/Server/RequestHandler.cpp b/Server/RequestHandler.cpp index 664bdf35a..f921ca1f9 100644 --- a/Server/RequestHandler.cpp +++ b/Server/RequestHandler.cpp @@ -37,8 +37,6 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include #include -#include - #include #include diff --git a/prepare.cpp b/prepare.cpp index 282d5d922..fa520880c 100644 --- a/prepare.cpp +++ b/prepare.cpp @@ -43,7 +43,6 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "Util/StringUtil.h" #include "typedefs.h" -#include #include #include @@ -334,7 +333,7 @@ int main (int argc, char *argv[]) { boost::filesystem::ofstream hsgr_output_stream(graphOut, std::ios::binary); hsgr_output_stream.write((char*)&uuid_orig, sizeof(UUID) ); - BOOST_FOREACH(const QueryEdge & edge, contractedEdgeList) + for (const QueryEdge & edge : contractedEdgeList) { BOOST_ASSERT( UINT_MAX != edge.source ); BOOST_ASSERT( UINT_MAX != edge.target );