Randomly rearranging the elements in a vector
Hello, it's been quite some time since I've come to these forums. Anyway! I have a question about using the C++ vector class (from the standard). I want to perform an action to each and every element in one of my vectors, but I want the order of elements I perform the action on to be random.
I was thinking one way to do this would be to just implement some algorithm that randomly rearranged all the elements in the vector, and then to go through the randomly rearranged vector sequentially performing the action. Is there any algorithm that could randomly sort a vector that would be easy to implement?
Might there be a much better way here of doing what I'm trying to do that I'm not thinking of? (I am definitely not a C++ programmer!)
Also, I've been wondering whether vector is the best class to use for what I'm trying to do. I need a list of elements, where I can add to the back of the list and remove from anywhere in the list. The list will also quickly grow to very large sizes (200,000+ elements). Is there some class other than vector which might be better for this?
Last but not least: Say I want to remove the 53rd element from a vector called bob. Must I say, bob.erase(bob.begin() + 53)?
Thank you so much. This is really important to me.