Is it possible to insert an element directly into it's 'right' place in an ordered vector, instead of using push_back() and then sort()? If not, is it possible with a list?
Is it possible to insert an element directly into it's 'right' place in an ordered vector, instead of using push_back() and then sort()? If not, is it possible with a list?
Thanks,
Avi.
I agree with Banfa, use something like this,
vector<int> vec;
vec.insert(vec. begin(), 5); //This will place 5 at the beginning
vec.insert(vec. begin(), 4); //This will place 4 before 5
Comment