I need to have sorted array of thousands of records. I put everytime new record on the right place, thus I must change index of the rest of the records in my array. I make in manualy like:
db[j]=record;
cout<<tmp.oName<<endl;
while (j++!=size-1){
tmp2=db[j];
db[j]=tmp;
tmp=db[j];
}
And here comes my question: would it be significantly faster to create new array and use copy, or there would be no noticeable computing time and memory usage enhancement beside my current code? I'm quite new to C++, so I'm not sure, how this function internally works.
Includes, I can use:
#include <iostream>
#include <iomanip>
#include <string>
#include <cstring>
#include <cstdlib>
#include <cstdio>
std::(multi)set. It keeps the elements sorted.std::setis possible in your situation.std::vector::insertto perform this. It will move everything for you.