Unoptimized problem: I work on a table (vector of vectors). vector< vector<double> >
Optimization: If the current set of vectors is v1...vn (so each vk is a vector of double), my problem is such that I will only work on the last M of the vectors, the earlier vectors are irrelevant. I would like to reuse space to make the algorithm scalable, so I want to delete the vectors that can be forgotten. I read in a new vector, I delete the oldest vector.
The problem is that naive deletion of vectors is expensive. There must be a simple way to do this since this is a special and simple kind of deletion.
deque's allow for quick erasure of elements at both ends. So you can use it as a continuous stream: You can push elements to the end of it, while popping them off of the front. And still allow fast random access.