Quote:
|
Originally Posted by grumpy
Accessing elements or appending to the end is fast (technically: constant). Inserting elements in is moderately fast (technically: linear with number of elements). Deletions from the middle are slow.
|
Inserting elements in the middle of a vector suffers the same problem as deleting elements from the middle - the rest of the vector has to be shuffled around - they are both slow.
Also, appending to the end of a vector may occasionally cause the whole vector to be reallocated and all of the items to be moved. This can be very bad, but using reserve() can help a bit.
std::deque containers are better for when you are continually adding to the end.