Isn't the time complexity a little high, when for (auto x : m) { ... }? One iteration calls fifo_map_compare n^2 times.
I think the time complexity of such a structure can be lower:
- one map: {Key, Value is pointer to node of queue}
- one queue: fifo, node{key, value}
For loop just iterates through the queue.
Looking forward to your reply!