Say I have a high score table structured like
name score
name score
....
I need to do some file operations and manipulate certain areas of the file, and I thought the best way to do this would be to store it in a container that preserved the order of the file, do the data manipulation with the container, then output back to the file.
I considered using a map< std::string, int >
, but a map wouldn't preserve the order of the file. Would a vector< pair< std::string, int >>
be better, or is there some kind of ordered map I can use? I also need the container to repeat a name if necessary. I think a multimap keeps one key, but allows multiple values for that key, which isn't what I want since it wouldn't preserve order.