Skip to main content
gamedev.net
🔒 Locked

randomizing a multimap

Started by david6327 2 replies 900+ views
Original Post
david6327
david6327
is there a way to randomly sort a multimap?
SiCrane
SiCrane
Not really. A multimap is supposed to store things in a strict weak ordering. If you try a random order you probably won't be able to do lookups.
david6327
david6327
Unless you need lookups in random order.
Fruny
Fruny
Then a multimap isn't what you need. Either copy your data or multimap::iterator to your data into a random-access sequence (vector, deque), and random_shuffle it.
"Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." — Brian W. Kernighan

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.