Hi, I have written a Solitaire game program and have made a history of moves so the user may either go back on moves and make another choice or go forward after having gone back. Now I am using a vector to store the moves.

When the user has made several moves, decides to use the history to go back several moves and then plays a new move, the vector uses the pop_back() method to get rid of the moves on which the user has gone back. The process of poping back several moves is quite slow. Is this a drawback of the vector?

May thanks

the pop_back() method should be working efficiently. There is no way of telling, without seeing the code, there are probably some inefficiences that you have written. What kind of algorithm have you written to implement pop_back()?

I suggest you look at http://www.tantalon.com/pete/cppopt/main.htm

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.