I need to store a number of key/value pairs and access them again referenced by key - not necessarily in a map, although this seems natural. Additionally, if the map exceeds a certain size, I need to delete the oldest pairs.
Is there a way to implement this using a map or a similar structure somehow combining a map and a queue in C++11?
UPDATE: I wanted to this with a std::unsorted_map
. Unfortunately I'm heavily missing std::map
functions which would help. The unordered list seems neither to support rbegin()
nor does its iterator support the --
operator, so that I can't use end()
either.
Is there a better way than iterating through a loop to size()-1
?