-
Vector class
Ok maybe this time I'll actually post to the right board.
Is there a STL method which will return a random element from a vector? Its easy enough to write such a method, but I was just wondering if one exists already. I've searched on google to no avail.
Thanks.
-
random
The whole point of a vector is to have sequential predictable access in O(1).
If you want random access to a member you can always do:
std::vector v;
...
v[(int)(rand()*v.size())]
...
or similar depending how random you want it (rand is not new random as you know
-
Popular pages
Recent additions