So I have an unordered map, and for each key I want to store two unique floats. These floats represent aggregate values over time of something I am simulating, and thus as my code progresses they values of existing keys may be added to, and new keys may be created.
Previously I was only tracking one value, and so an unordered map was the easy solution. I am not sure how to save two distinct values with one key though?
You could use an
unordered_map< int, std::pair< float, float > >, accessing the values via the
.second functions of the pair. I'm not sure that that is "easier" then using the
vector< float > approach though. The vector approach has the advantage of allowing you to expand to store more values with ease. The
pair approach has the advantage of being explicitly two values and only two values.