randomizing a multimap

Started by
2 comments, last by Fruny 17 years, 9 months ago
is there a way to randomly sort a multimap?
Advertisement
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.
Unless you need lookups in random order.
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

This topic is closed to new replies.

Advertisement