Listing 2: Measurements Sorting a vector<string> (only main is shown; everything else is the same as in Listing 1)
int main(int argc, const char** argv) { if (argc != 2) { std::cerr << "Usage: " << argv[0] << " <file>" << std::endl; return 1; } std::ifstream in(argv[1]); if (!in) { std::cerr << "Can't open " << argv[1] << std::endl; return 1; } vector<string> v; string str; while (std::getline(in, str)) v.push_back(str); std::cout << "Sorting a file of " << v.size() << " lines." << std::endl; vector<pair<string, double> > results; results.push_back(do_sort(v)); results.push_back(do_stable_sort(v)); results.push_back(do_heap_sort(v)); results.push_back(do_list_sort(v)); results.push_back(do_set_sort(v)); report(results, std::cout); return 0; }