@@ -248,7 +248,7 @@ int main(int argc, char *argv[])
248
248
}
249
249
cout << endl;
250
250
// at the end, print the lines ignored
251
- for (string l : ignoring) cout << l << endl;
251
+ for (string& l : ignoring) cout << l << endl;
252
252
ignoring.clear ();
253
253
}
254
254
file.close ();
@@ -285,9 +285,8 @@ int main(int argc, char *argv[])
285
285
#else
286
286
for (HighwaySystem* h : highway_systems)
287
287
{ std::cout << h->systemname << std::flush;
288
- for (std::list<Route>::iterator r = h->route_list .begin (); r != h->route_list .end (); r++)
289
- { r->read_wpt (&all_waypoints, &el, args.highwaydatapath +" /hwy_data" , datacheckerrors, &all_wpt_files);
290
- }
288
+ for (Route& r : h->route_list )
289
+ r.read_wpt (&all_waypoints, &el, args.highwaydatapath +" /hwy_data" , datacheckerrors, &all_wpt_files);
291
290
std::cout << " !" << std::endl;
292
291
}
293
292
#endif
@@ -529,7 +528,7 @@ int main(int argc, char *argv[])
529
528
{ inusefile << r.root << ' (' << r.point_list .size () << " ):" ;
530
529
list<string> liu_list (r.labels_in_use .begin (), r.labels_in_use .end ());
531
530
liu_list.sort ();
532
- for (string label : liu_list) inusefile << ' ' << label;
531
+ for (string& label : liu_list) inusefile << ' ' << label;
533
532
inusefile << ' \n ' ;
534
533
r.labels_in_use .clear ();
535
534
}
@@ -546,7 +545,7 @@ int main(int argc, char *argv[])
546
545
string ual_entry = r.root + ' (' + to_string (r.unused_alt_labels .size ()) + " ):" ;
547
546
list<string> ual_list (r.unused_alt_labels .begin (), r.unused_alt_labels .end ());
548
547
ual_list.sort ();
549
- for (string label : ual_list) ual_entry += ' ' + label;
548
+ for (string& label : ual_list) ual_entry += ' ' + label;
550
549
r.unused_alt_labels .clear ();
551
550
unused_alt_labels.push_back (ual_entry);
552
551
}
@@ -656,15 +655,15 @@ int main(int argc, char *argv[])
656
655
region_entries.push_back (region->code + fstr);
657
656
}
658
657
region_entries.sort ();
659
- for (string e : region_entries) hdstatsfile << e;
658
+ for (string& e : region_entries) hdstatsfile << e;
660
659
661
660
for (HighwaySystem *h : highway_systems)
662
661
{ sprintf (fstr, " ) total: %.2f mi\n " , h->total_mileage ());
663
662
hdstatsfile << " System " << h->systemname << " (" << h->level_name () << fstr;
664
663
if (h->mileage_by_region .size () > 1 )
665
664
{ hdstatsfile << " System " << h->systemname << " by region:\n " ;
666
665
list<Region*> regions_in_system;
667
- for (pair<Region*, double > rm : h->mileage_by_region )
666
+ for (pair<Region* const , double >& rm : h->mileage_by_region )
668
667
regions_in_system.push_back (rm.first );
669
668
regions_in_system.sort (sort_regions_by_code);
670
669
for (Region *r : regions_in_system)
@@ -673,19 +672,19 @@ int main(int argc, char *argv[])
673
672
}
674
673
}
675
674
hdstatsfile << " System " << h->systemname << " by route:\n " ;
676
- for (list< ConnectedRoute>::iterator cr = h->con_route_list . begin (); cr != h-> con_route_list . end (); cr++ )
675
+ for (ConnectedRoute& cr : h->con_route_list )
677
676
{ double con_total_miles = 0 ;
678
677
string to_write = " " ;
679
- for (Route *r : cr-> roots )
678
+ for (Route *r : cr. roots )
680
679
{ sprintf (fstr, " : %.2f mi\n " , r->mileage );
681
680
to_write += " " + r->readable_name () + fstr;
682
681
con_total_miles += r->mileage ;
683
682
}
684
- cr-> mileage = con_total_miles; // FIXME?
683
+ cr. mileage = con_total_miles; // FIXME?
685
684
sprintf (fstr, " : %.2f mi" , con_total_miles);
686
- hdstatsfile << cr-> readable_name () << fstr;
687
- if (cr-> roots .size () == 1 )
688
- hdstatsfile << " (" << cr-> roots [0 ]->readable_name () << " only)\n " ;
685
+ hdstatsfile << cr. readable_name () << fstr;
686
+ if (cr. roots .size () == 1 )
687
+ hdstatsfile << " (" << cr. roots [0 ]->readable_name () << " only)\n " ;
689
688
else hdstatsfile << ' \n ' << to_write;
690
689
}
691
690
}
@@ -733,7 +732,7 @@ int main(int argc, char *argv[])
733
732
allfile << ' \n ' ;
734
733
for (TravelerList *t : traveler_lists)
735
734
{ double t_total_mi = 0 ;
736
- for (std::pair<Region*, double > rm : t->active_only_mileage_by_region )
735
+ for (std::pair<Region* const , double >& rm : t->active_only_mileage_by_region )
737
736
t_total_mi += rm.second ;
738
737
sprintf (fstr, " %.2f" , t_total_mi);
739
738
allfile << t->traveler_name << ' ,' << fstr;
@@ -771,7 +770,7 @@ int main(int argc, char *argv[])
771
770
allfile << ' \n ' ;
772
771
for (TravelerList *t : traveler_lists)
773
772
{ double t_total_mi = 0 ;
774
- for (std::pair<Region*, double > rm : t->active_preview_mileage_by_region )
773
+ for (std::pair<Region* const , double >& rm : t->active_preview_mileage_by_region )
775
774
t_total_mi += rm.second ;
776
775
sprintf (fstr, " %.2f" , t_total_mi);
777
776
allfile << t->traveler_name << ' ,' << fstr;
@@ -799,7 +798,7 @@ int main(int argc, char *argv[])
799
798
sysfile << " Traveler,Total" ;
800
799
regions.clear ();
801
800
total_mi = 0 ;
802
- for (std::pair<Region*, double > rm : h->mileage_by_region )
801
+ for (std::pair<Region* const , double >& rm : h->mileage_by_region )
803
802
{ regions.push_back (rm.first );
804
803
total_mi += rm.second ; // TODO is this right?
805
804
}
@@ -835,7 +834,7 @@ int main(int argc, char *argv[])
835
834
cout << et.et () << " Reading datacheckfps.csv." << endl;
836
835
file.open (args.highwaydatapath +" /datacheckfps.csv" );
837
836
getline (file, line); // ignore header line
838
- list<array<string, 6 >> datacheckfps; // FIXME try implementing as an unordered_multiset; see if speed increases
837
+ list<array<string, 6 >> datacheckfps;
839
838
unordered_set<string> datacheck_always_error
840
839
({ " BAD_ANGLE" , " DUPLICATE_LABEL" , " HIDDEN_TERMINUS" ,
841
840
" INVALID_FINAL_CHAR" , " INVALID_FIRST_CHAR" ,
@@ -881,22 +880,22 @@ int main(int argc, char *argv[])
881
880
fpfile << " Log file created at: " << ctime (×tamp);
882
881
unsigned int counter = 0 ;
883
882
unsigned int fpcount = 0 ;
884
- for (list< DatacheckEntry>::iterator d = datacheckerrors->entries . begin (); d != datacheckerrors-> entries . end (); d++ )
883
+ for (DatacheckEntry& d : datacheckerrors->entries )
885
884
{ // cout << "Checking: " << d->str() << endl;
886
885
counter++;
887
886
if (counter % 1000 == 0 ) cout << ' .' << flush;
888
887
for (list<array<string, 6 >>::iterator fp = datacheckfps.begin (); fp != datacheckfps.end (); fp++)
889
- if (d-> match_except_info (*fp))
890
- if (d-> info == (*fp)[5 ])
888
+ if (d. match_except_info (*fp))
889
+ if (d. info == (*fp)[5 ])
891
890
{ // cout << "Match!" << endl;
892
- d-> fp = 1 ;
891
+ d. fp = 1 ;
893
892
fpcount++;
894
893
datacheckfps.erase (fp);
895
894
break ;
896
895
}
897
896
else
898
897
{ fpfile << " FP_ENTRY: " << (*fp)[0 ] << ' ;' << (*fp)[1 ] << ' ;' << (*fp)[2 ] << ' ;' << (*fp)[3 ] << ' ;' << (*fp)[4 ] << ' ;' << (*fp)[5 ] << ' \n ' ;
899
- fpfile << " CHANGETO: " << (*fp)[0 ] << ' ;' << (*fp)[1 ] << ' ;' << (*fp)[2 ] << ' ;' << (*fp)[3 ] << ' ;' << (*fp)[4 ] << ' ;' << d-> info << ' \n ' ;
898
+ fpfile << " CHANGETO: " << (*fp)[0 ] << ' ;' << (*fp)[1 ] << ' ;' << (*fp)[2 ] << ' ;' << (*fp)[3 ] << ' ;' << (*fp)[4 ] << ' ;' << d. info << ' \n ' ;
900
899
}
901
900
}
902
901
fpfile.close ();
@@ -910,8 +909,8 @@ int main(int argc, char *argv[])
910
909
timestamp = time (0 );
911
910
fpfile << " Log file created at: " << ctime (×tamp);
912
911
if (datacheckfps.empty ()) fpfile << " No unmatched FP entries.\n " ;
913
- else for (array<string, 6 > entry : datacheckfps)
914
- fpfile << entry[0 ] << ' ;' << entry[1 ] << ' ;' << entry[2 ] << ' ;' << entry[3 ] << ' ;' << entry[4 ] << ' ;' << entry[5 ] << ' \n ' ;
912
+ else for (array<string, 6 >& entry : datacheckfps)
913
+ fpfile << entry[0 ] << ' ;' << entry[1 ] << ' ;' << entry[2 ] << ' ;' << entry[3 ] << ' ;' << entry[4 ] << ' ;' << entry[5 ] << ' \n ' ;
915
914
fpfile.close ();
916
915
917
916
// datacheck.log file
@@ -999,7 +998,7 @@ int main(int argc, char *argv[])
999
998
unsigned other_count = 0;
1000
999
unsigned int total_rtes = 0;
1001
1000
for (HighwaySystem *h : highway_systems)
1002
- for (Route r : h->route_list)
1001
+ for (Route& r : h->route_list)
1003
1002
{ total_rtes++;
1004
1003
if (h->devel()) d_count++;
1005
1004
else { if (h->active()) a_count++;
0 commit comments