dimanche 16 décembre 2018

What is the fastest way to get a random element from an unordered_set? [duplicate]

The question itself is pretty straightforward.

I know that I could generate a random value R between 0 and the size of the container, create an iterator over it and advance it by R, but this seems to be O(R) and I think there could be a faster way to get random elements inside an unordered_set.




Aucun commentaire:

Enregistrer un commentaire