c++ - insert performance sort data in list and vector -
in principle , practice book of bjarne stroustrup there exercise in chapter 20 asks insert random value in vector , list in sort way (experiment suggested jhon bentley) this code (if there better way doing sorry ) #include <vector> #include <list> #include <iostream> #include <ctime> #include <random> #include <chrono> using namespace std; template<typename iter, typename t> int find_index(iter start, iter end, const t& value) { int index = 0; while (start != end) { while (start!=end && value >= *start) { ++index; ++start; } return index; } return -1; } template<typename iter> void print(iter first,iter end) { while (first != end) { cout << *first << endl; first++; } } int generate_random(int min, int max) { random_device device; mt19937 generator{ device() }; uniform_int_distribution...