jeudi 25 février 2016

The order of restitution of the elements of a map not changed is always the same?

map<vector<int>,int> > mymap

I wonder if the order of items in a map can change if over mymap does not do anything. That is, suppose that the map has 3 pairs that I call 1 2 3 and when I go into the map whit this code :

for(auto i = mymap.begin();i!=mymap.end();i++)
{
    cout<<i->first<<endl; //operator<< is redefenid
}

the element are returned in this order: 3 2 1 Later without making any changes to the map with the same code above I have the assurance that the elements are accessed in the same order as before (namely 3 2 1)? (I use C++11)

Aucun commentaire:

Enregistrer un commentaire