I need to iterate through an std::map's elements in the same order that they were inserted into the map. Can it be done? If so, can anyone post a code example of it in action?
Thanks in advance.
I need to iterate through an std::map's elements in the same order that they were inserted into the map. Can it be done? If so, can anyone post a code example of it in action?
Thanks in advance.
I'm an alien from another world. Planet Earth is only my vacation home, and I'm not liking it.
No, you need to keep track of the insertion order yourself.
Look up a C++ Reference and learn How To Ask Questions The Smart WayOriginally Posted by Bjarne Stroustrup (2000-10-14)
A vector of map iterators, perhaps. You have to keep the vector up to date as well, as operations on the map can invalidate iterators, including and not limited to removing pairs.