Skip to content

Instantly share code, notes, and snippets.

@joboccara
Created January 27, 2017 08:27
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