// test_algorithms.cpp not exhaustive, just some functions #include #include #include using namespace std; static int pos_nums() { static int i=1; return i++; } // 1, 2, 3, ... template void put(typ msg) { cout << ' ' << msg; } // put any type with a leading space int main() { vector a(10); put("test_algorithms.cpp running on size"); // put put((int)a.size()); // put put('\n'); // put generate(a.begin(), a.end(), pos_nums); // pos_mums generates values cout << "generate "; for_each(a.begin(), a.end(), put); // print values cout << endl; random_shuffle(a.begin(), a.end()); // shuffle cout << "randomized "; for_each(a.begin(), a.end(), put); cout << endl; sort(a.begin(), a.end()); // sort cout << "sorted "; for_each(a.begin(), a.end(), put); cout << endl; reverse(a.begin(), a.end()); // reverse order cout << "reversed "; for_each(a.begin(), a.end(), put); cout << endl; return 0; }