Created
January 27, 2017 08:27
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int computeNumberOfBreaks(const std::vector<City>& route) | |
{ | |
static const double MaxDistance = 100; | |
int nbBreaks = 0; | |
for (std::vector<City>::const_iterator it1 = route.begin(), it2 = route.end(); | |
it1 != route.end(); | |
it2 = it1, ++it1) | |
{ | |
if (it2 != route.end()) | |
{ | |
if(it1->getGeographicalAttributes().getLocation().distanceTo( | |
it2->getGeographicalAttributes().getLocation()) > MaxDistance) | |
{ | |
++nbBreaks; | |
} | |
} | |
} | |
return nbBreaks; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment