Hi,
Say you're programming a game, and in this game, you have 5 players. Each player can have a score between 0 and 100, and is identified by a unique integer ID that's between 0 and 100. Their scores can sometimes be the same. You want to be able to output the scores from highest to lowest at any point in the game, and also sometimes check who is at the top/ bottom of the scoreboard.
Which STL container would be the best for this? I'm thinking a multimap, using the score for the key, and the ID for the mapped value. This way the scores would always be sorted whenever you wanted to access them.
Does this make sense or would another container be better?
Thanks.



LinkBack URL
About LinkBacks



air for the convenience. I can quickly establish all manner of sort algorithms fron the value instead of they key. Meanwhile, I do tend to choose only maps when the key is a stronger element. When it is just a needed associative nuisance, I prefer the flexibility of vectors.