Hi,
Let me explain a little background of the situation in case there is a wiser solution than vectors. I've got a loop running in a program, and for each loop, I need to add a new element at the end. I need to backtrack anywhere from 5 - 250 elements. The amount I need to backtrack does not remain constant throughout the program. The problem(I think) is that after a while, it would just keep allocating memory when I don't need it. At a certain point, I want to delete the first element, freeing that memory space up.
My first thought was to use a vector, but I'm not sure if there is a way to do what I want. I looked through some reference material and I found vector::resize
, but it sounds like if I want to restrain it, it deletes elements at the end instead of the first elements. I'm not totally familiar with all of the STL containers, so maybe another one would suit it better. Any ideas or suggestions?