Zaphod <fo*@bar.com> wrote in news:250420041528296467%fo*@bar.com:
I'm using an STL stack to hold objects. I need to randomize the
contents of the stack. Is there a simple way to do this?
Simplicity is relative.
There is no standard way to do that.
You need to roll an algorithm yourself. It would probably involve copying
contents of the stack into a new one, I'm afraid.
Given your stack is std::vector based, you could for example quickly pick
out indices for copying using rand(). It all depends on what degree of
randomness you expect.
Just off the top of my head... There are better approaches, I'm sure.
Cheers
b