[c++]vector insert method

Suppose I'd like to copy an array of ints into the front of a vector. (The
data might be in an array instead of a vector in the first place, because the data came from a legacy C API. )
What is the performance wise difference in the two method:

int data[numValues];
vector<int>::iterator insertLoc(v.begin());
for (int i = 0; i < numValues; ++i) {
insertLoc = v.insert(insertLoc, data[i]);
}

Comments

Popular posts from this blog