lallous wrote:
Hello,
I noticed that as I insert items to std::map<std::string, std::string> map1
as:
map1["test"] = "hello";
map1["hello"] = "test";
Then use an iterator to walk in the map, the items will be retrieved by the
alphabetical order of the keys...is there is a way to allow std::map to enum
items in the order of insertion?
--
Elias
From the implementations of the map containers I have seen, the map is
stored in a red-black, ordered tree. This greatly increases the lookup
speed. Storing in input order is very slow, and would make most
instances of std::map useless to the programmer.
If you want something ordered in the order they were put in there, use a
vector or list of pairs, and do a scan of the container (for loop) for
the key.
Brian