Tessil / ordered-map

C++ hash map and hash set which preserve the order of insertion
MIT License
512 stars 66 forks source link

How to get an element by a random number? #31

Closed pengweichu closed 3 years ago

pengweichu commented 3 years ago

Hi,

How can I get an element by a random number?

Update: I think the nth method is it, right?

Thanks!

Tessil commented 3 years ago

Hi,

Yes if you want an element at a random index in the hash-map/set, generate a number between [0;size) and use nth.