But if it is ensured that I am always adding to the end of the list, the cost of push_back to vector is very small compared to the cost of insert to a queue. |
That isn't necessarily true. In fact, in some cases, it is quite false. If you push_back() onto a vector that has insufficient space, the entire vector gets copied. If you push_back() onto a deque that has insufficient space, none of your elements are copied (though some of deque's internal housekeeping may, but that is fairly insignificant). push_back() onto a deque with sufficient space is as fast as push_back() onto a vctor with sufficient space.
The trouble lies in that most vector<> implementations I know of use one of the worst possible allocation schemes: any time the vector must grow, it doubles in size. It has been shown that this will tend to fragment your heap because each successive doubling of size cannot reuse any of the memory space it used before. In fact, the best way to grow the vector is by the golden ratio. But anyway, given that vector doubles in size, if your vector starts out empty, you'll reallocate when you insert the 1st, 2nd, 4th, 8th, 16th, 32nd, and so forth elements. If your vector is only going to grow to a maximum of 10 elements, you'll reallocate 4 times, and in the process copy 11 elements (on the 2nd insert, you'll copy 1; on the 4th, you'll copy the existing 3; on the 8th insert you'll copy the existing 7). Which is essentially 21 object constructions (11 copies plus the 10 you put in). With std::deque, you'll get 10 constructions period.
(EDIT: Of course you can mitigate the above by using std::vector<>::reserve() before doing any inserts).
If you are afraid of copying whole vectors because you need to insert a new vector in alist between elements i and i+1, then I'd suggest using a std::list< std::vector > instead. While it might be ever so slightly slower, it alleviates you from having to manage
the memory.