remove (almost) all BOOST_FOREACH calls

This commit is contained in:
Dennis Luxen 2014-05-07 16:17:47 +02:00
parent e3244dd649
commit 9710f39cad
12 changed files with 32 additions and 45 deletions

View File

@ -40,7 +40,6 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "../Util/StringUtil.h" #include "../Util/StringUtil.h"
#include <boost/assert.hpp> #include <boost/assert.hpp>
#include <boost/foreach.hpp>
#include <boost/lambda/lambda.hpp> #include <boost/lambda/lambda.hpp>
#include <boost/make_shared.hpp> #include <boost/make_shared.hpp>
#include <boost/shared_ptr.hpp> #include <boost/shared_ptr.hpp>
@ -263,7 +262,7 @@ public:
std::cout << " [flush " << numberOfContractedNodes << " nodes] " << std::flush; std::cout << " [flush " << numberOfContractedNodes << " nodes] " << std::flush;
//Delete old heap data to free memory that we need for the coming operations //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; delete data;
} }
threadData.clear(); threadData.clear();
@ -380,7 +379,7 @@ public:
//insert new edges //insert new edges
for ( unsigned threadNum = 0; threadNum < maxThreads; ++threadNum ) { for ( unsigned threadNum = 0; threadNum < maxThreads; ++threadNum ) {
_ThreadData& data = *threadData[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); _DynamicGraph::EdgeIterator currentEdgeID = _graph->FindEdge(edge.source, edge.target);
if(currentEdgeID < _graph->EndEdges(edge.source) ) { if(currentEdgeID < _graph->EndEdges(edge.source) ) {
_DynamicGraph::EdgeData & currentEdgeData = _graph->GetEdgeData(currentEdgeID); _DynamicGraph::EdgeData & currentEdgeData = _graph->GetEdgeData(currentEdgeID);
@ -436,7 +435,7 @@ public:
p.printStatus(numberOfContractedNodes); p.printStatus(numberOfContractedNodes);
} }
BOOST_FOREACH(_ThreadData * data, threadData) { for(_ThreadData * data : threadData) {
delete data; delete data;
} }
threadData.clear(); threadData.clear();
@ -711,7 +710,7 @@ private:
std::sort( neighbours.begin(), neighbours.end() ); std::sort( neighbours.begin(), neighbours.end() );
neighbours.resize( std::unique( neighbours.begin(), neighbours.end() ) - neighbours.begin() ); 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 ); priorities[u] = _Evaluate( data, &( nodeData )[u], u );
} }
return true; return true;
@ -744,11 +743,13 @@ private:
neighbours.resize( std::unique( neighbours.begin(), neighbours.end() ) - neighbours.begin() ); neighbours.resize( std::unique( neighbours.begin(), neighbours.end() ) - neighbours.begin() );
//examine all neighbours that are at most 2 hops away //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 ) { for ( _DynamicGraph::EdgeIterator e = _graph->BeginEdges( u ) ; e < _graph->EndEdges( u ) ; ++e ) {
const NodeID target = _graph->GetTarget( e ); const NodeID target = _graph->GetTarget( e );
if(node==target) if(node==target)
{
continue; continue;
}
const double targetPriority = priorities[target]; const double targetPriority = priorities[target];
assert( targetPriority >= 0 ); assert( targetPriority >= 0 );

View File

@ -31,7 +31,6 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <boost/assert.hpp> #include <boost/assert.hpp>
#include <boost/filesystem.hpp> #include <boost/filesystem.hpp>
#include <boost/filesystem/fstream.hpp> #include <boost/filesystem/fstream.hpp>
#include <boost/foreach.hpp>
#include <limits> #include <limits>
@ -101,7 +100,7 @@ void GeometryCompressor::SerializeInternalVector(const std::string &path) const
const unsigned unpacked_size = current_vector.size(); const unsigned unpacked_size = current_vector.size();
control_sum += unpacked_size; control_sum += unpacked_size;
BOOST_ASSERT(UINT_MAX != 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)); 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 number_of_compressed_geometries = 0;
uint64_t longest_chain_length = 0; uint64_t longest_chain_length = 0;
BOOST_FOREACH (const std::vector<CompressedNode> &current_vector, m_compressed_geometries) for (const std::vector<CompressedNode> &current_vector : m_compressed_geometries)
{ {
number_of_compressed_geometries += current_vector.size(); number_of_compressed_geometries += current_vector.size();
longest_chain_length = std::max(longest_chain_length, (uint64_t)current_vector.size()); longest_chain_length = std::max(longest_chain_length, (uint64_t)current_vector.size());

View File

@ -36,7 +36,6 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <boost/algorithm/string.hpp> #include <boost/algorithm/string.hpp>
#include <boost/algorithm/string/regex.hpp> #include <boost/algorithm/string/regex.hpp>
#include <boost/foreach.hpp>
#include <boost/regex.hpp> #include <boost/regex.hpp>
BaseParser::BaseParser( BaseParser::BaseParser(
@ -76,7 +75,7 @@ void BaseParser::ReadRestrictionExceptions() {
const unsigned exception_count = restriction_exceptions.size(); const unsigned exception_count = restriction_exceptions.size();
SimpleLogger().Write() << SimpleLogger().Write() <<
"Found " << exception_count << " exceptions to turn restrictions:"; "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; SimpleLogger().Write() << " " << str;
} }
} else { } else {
@ -124,7 +123,7 @@ bool BaseParser::ShouldIgnoreRestriction(
//only a few exceptions are actually defined. //only a few exceptions are actually defined.
std::vector<std::string> exceptions; std::vector<std::string> exceptions;
boost::algorithm::split_regex(exceptions, except_tag_string, boost::regex("[;][ ]*")); 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<std::string>::const_iterator string_iterator; std::vector<std::string>::const_iterator string_iterator;
string_iterator = std::find( string_iterator = std::find(
restriction_exceptions.begin(), restriction_exceptions.begin(),

View File

@ -31,7 +31,6 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "../Util/SimpleLogger.h" #include "../Util/SimpleLogger.h"
#include <boost/assert.hpp> #include <boost/assert.hpp>
#include <boost/foreach.hpp>
#include <boost/filesystem.hpp> #include <boost/filesystem.hpp>
#include <boost/filesystem/fstream.hpp> #include <boost/filesystem/fstream.hpp>
@ -461,7 +460,7 @@ void ExtractionContainers::PrepareData(
//compute total number of chars //compute total number of chars
unsigned total_number_of_chars = 0; 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(); total_number_of_chars += temp_string.length();
} }
//write total number of chars //write total number of chars
@ -471,7 +470,7 @@ void ExtractionContainers::PrepareData(
); );
//write prefixe sums //write prefixe sums
unsigned name_lengths_prefix_sum = 0; 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( name_file_stream.write(
(char *)&(name_lengths_prefix_sum), (char *)&(name_lengths_prefix_sum),
sizeof(unsigned) sizeof(unsigned)
@ -485,7 +484,7 @@ void ExtractionContainers::PrepareData(
); );
//write all chars consecutively //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(); const unsigned string_length = temp_string.length();
name_file_stream.write(temp_string.c_str(), string_length); name_file_stream.write(temp_string.c_str(), string_length);
} }

View File

@ -42,7 +42,6 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <osrm/Coordinate.h> #include <osrm/Coordinate.h>
#include <boost/foreach.hpp>
#include <boost/make_shared.hpp> #include <boost/make_shared.hpp>
#include <boost/ref.hpp> #include <boost/ref.hpp>
@ -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); 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()) if (2 <= extraction_way.path.size())
{ {

View File

@ -32,7 +32,6 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "../DataStructures/SearchEngineData.h" #include "../DataStructures/SearchEngineData.h"
#include <boost/assert.hpp> #include <boost/assert.hpp>
#include <boost/foreach.hpp>
#include <boost/unordered_map.hpp> #include <boost/unordered_map.hpp>
#include <vector> #include <vector>
@ -199,7 +198,7 @@ public:
unsigned index_into_forward_path = 0; unsigned index_into_forward_path = 0;
//sweep over search space, compute forward sharing for each current edge (u,v) //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 u = current_edge.first;
const NodeID v = current_edge.second; const NodeID v = current_edge.second;
if( if(
@ -217,7 +216,7 @@ public:
unsigned index_into_reverse_path = 0; unsigned index_into_reverse_path = 0;
//sweep over search space, compute backward sharing //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 u = current_edge.first;
const NodeID v = current_edge.second; const NodeID v = current_edge.second;
if( if(
@ -239,7 +238,8 @@ public:
// SimpleLogger().Write(logDEBUG) << "rev_search_space size: " << reverse_search_space.size() << ", marked " << approximated_reverse_sharing.size() << " nodes"; // SimpleLogger().Write(logDEBUG) << "rev_search_space size: " << reverse_search_space.size() << ", marked " << approximated_reverse_sharing.size() << " nodes";
std::vector<NodeID> preselected_node_list; std::vector<NodeID> preselected_node_list;
BOOST_FOREACH(const NodeID node, via_node_candidate_list) { for (const NodeID node : via_node_candidate_list)
{
boost::unordered_map<NodeID, int>::const_iterator fwd_iterator = approximated_forward_sharing.find(node); boost::unordered_map<NodeID, int>::const_iterator fwd_iterator = approximated_forward_sharing.find(node);
const int fwd_sharing = (fwd_iterator != approximated_forward_sharing.end()) ? fwd_iterator->second : 0; const int fwd_sharing = (fwd_iterator != approximated_forward_sharing.end()) ? fwd_iterator->second : 0;
boost::unordered_map<NodeID, int>::const_iterator rev_iterator = approximated_reverse_sharing.find(node); boost::unordered_map<NodeID, int>::const_iterator rev_iterator = approximated_reverse_sharing.find(node);
@ -269,7 +269,7 @@ public:
std::vector<RankedCandidateNode> ranked_candidates_list; std::vector<RankedCandidateNode> ranked_candidates_list;
//prioritizing via nodes for deep inspection //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; int length_of_via_path = 0, sharing_of_via_path = 0;
ComputeLengthAndSharingOfViaPath(node, &length_of_via_path, &sharing_of_via_path, packed_shortest_path); 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; const int maximum_allowed_sharing = upper_bound_to_shortest_path_distance*VIAPATH_GAMMA;
@ -291,7 +291,7 @@ public:
NodeID selected_via_node = SPECIAL_NODEID; NodeID selected_via_node = SPECIAL_NODEID;
int length_of_via_path = INVALID_EDGE_WEIGHT; int length_of_via_path = INVALID_EDGE_WEIGHT;
NodeID s_v_middle = SPECIAL_NODEID, v_t_middle = SPECIAL_NODEID; 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)) { 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 // select first admissable
selected_via_node = candidate.node; selected_via_node = candidate.node;

View File

@ -35,7 +35,6 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "../Util/SimpleLogger.h" #include "../Util/SimpleLogger.h"
#include <boost/assert.hpp> #include <boost/assert.hpp>
#include <boost/foreach.hpp>
#include <boost/noncopyable.hpp> #include <boost/noncopyable.hpp>
#include <stack> #include <stack>

View File

@ -29,7 +29,6 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#define SHORTESTPATHROUTING_H_ #define SHORTESTPATHROUTING_H_
#include <boost/assert.hpp> #include <boost/assert.hpp>
#include <boost/foreach.hpp>
#include "BasicRoutingInterface.h" #include "BasicRoutingInterface.h"
#include "../DataStructures/SearchEngineData.h" #include "../DataStructures/SearchEngineData.h"
@ -57,10 +56,8 @@ public:
RawRouteData & raw_route_data RawRouteData & raw_route_data
) const ) const
{ {
BOOST_FOREACH( for (const PhantomNodes & phantom_node_pair : phantom_nodes_vector)
const PhantomNodes & phantom_node_pair, {
phantom_nodes_vector
){
if( phantom_node_pair.AtLeastOnePhantomNodeIsInvalid() ) { if( phantom_node_pair.AtLeastOnePhantomNodeIsInvalid() ) {
// raw_route_data.lengthOfShortestPath = INT_MAX; // raw_route_data.lengthOfShortestPath = INT_MAX;
// raw_route_data.lengthOfAlternativePath = INT_MAX; // raw_route_data.lengthOfAlternativePath = INT_MAX;
@ -93,9 +90,8 @@ public:
int current_leg = 0; int current_leg = 0;
//Get distance to next pair of target nodes. //Get distance to next pair of target nodes.
BOOST_FOREACH( for(const PhantomNodes & phantom_node_pair : phantom_nodes_vector)
const PhantomNodes & phantom_node_pair, phantom_nodes_vector {
){
forward_heap1.Clear(); forward_heap2.Clear(); forward_heap1.Clear(); forward_heap2.Clear();
reverse_heap1.Clear(); reverse_heap2.Clear(); reverse_heap1.Clear(); reverse_heap2.Clear();
int local_upper_bound1 = INT_MAX; int local_upper_bound1 = INT_MAX;

View File

@ -231,7 +231,7 @@ void Connection::compressBufferCollection(
boost::iostreams::back_inserter(compressed_data) boost::iostreams::back_inserter(compressed_data)
); );
BOOST_FOREACH( const std::string & line, uncompressed_data) { for ( const std::string & line : uncompressed_data) {
compressing_stream << line; compressing_stream << line;
} }

View File

@ -25,8 +25,6 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
#include <boost/foreach.hpp>
#include <osrm/Reply.h> #include <osrm/Reply.h>
#include "../../Util/StringUtil.h" #include "../../Util/StringUtil.h"
@ -34,7 +32,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
namespace http { namespace http {
void Reply::setSize(const unsigned size) { void Reply::setSize(const unsigned size) {
BOOST_FOREACH ( Header& h, headers) { for ( Header& h : headers) {
if("Content-Length" == h.name) { if("Content-Length" == h.name) {
intToString(size,h.value); intToString(size,h.value);
} }
@ -45,7 +43,7 @@ void Reply::setSize(const unsigned size) {
void Reply::SetUncompressedSize() void Reply::SetUncompressedSize()
{ {
unsigned uncompressed_size = 0; unsigned uncompressed_size = 0;
BOOST_FOREACH ( const std::string & current_line, content) for ( const std::string & current_line : content)
{ {
uncompressed_size += current_line.size(); uncompressed_size += current_line.size();
} }
@ -56,14 +54,14 @@ void Reply::SetUncompressedSize()
std::vector<boost::asio::const_buffer> Reply::toBuffers(){ std::vector<boost::asio::const_buffer> Reply::toBuffers(){
std::vector<boost::asio::const_buffer> buffers; std::vector<boost::asio::const_buffer> buffers;
buffers.push_back(ToBuffer(status)); 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(h.name));
buffers.push_back(boost::asio::buffer(seperators)); buffers.push_back(boost::asio::buffer(seperators));
buffers.push_back(boost::asio::buffer(h.value)); buffers.push_back(boost::asio::buffer(h.value));
buffers.push_back(boost::asio::buffer(crlf)); buffers.push_back(boost::asio::buffer(crlf));
} }
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)); buffers.push_back(boost::asio::buffer(line));
} }
return buffers; return buffers;

View File

@ -37,8 +37,6 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <osrm/Reply.h> #include <osrm/Reply.h>
#include <osrm/RouteParameters.h> #include <osrm/RouteParameters.h>
#include <boost/foreach.hpp>
#include <algorithm> #include <algorithm>
#include <iostream> #include <iostream>

View File

@ -43,7 +43,6 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "Util/StringUtil.h" #include "Util/StringUtil.h"
#include "typedefs.h" #include "typedefs.h"
#include <boost/foreach.hpp>
#include <boost/filesystem.hpp> #include <boost/filesystem.hpp>
#include <boost/filesystem/fstream.hpp> #include <boost/filesystem/fstream.hpp>
@ -334,7 +333,7 @@ int main (int argc, char *argv[]) {
boost::filesystem::ofstream hsgr_output_stream(graphOut, std::ios::binary); boost::filesystem::ofstream hsgr_output_stream(graphOut, std::ios::binary);
hsgr_output_stream.write((char*)&uuid_orig, sizeof(UUID) ); 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.source );
BOOST_ASSERT( UINT_MAX != edge.target ); BOOST_ASSERT( UINT_MAX != edge.target );