mardi 20 novembre 2018

C++11: does unordered_map/set guarantees traversing order as insert order?

I wrote some small code like

unordered_map<int, int> uii;
uii.insert(make_pair(12,4));
uii.insert(make_pair(3,2));
uii.insert(make_pair(6,1));
uii.insert(make_pair(16,9));
....

When I use for loop to visit this map, it prints key in the right order of my insertion. I tested unordered_set, same result.

So my question is, does c++ standard guarantees the visiting order as insert order, just like Java's LinkedHashMap?

Thanks a lot.

Aucun commentaire:

Enregistrer un commentaire