dictionary - C++: Why my hash_map is giving me an ordered result like a map? -


since map implemented using tree , hash_map using hash, created code test if map give me ordered result , hash_map print examples in order registered

map<string, int> mymap; hash_map<string, int> myhashmap;  mymap["lucas"] = 1; mymap["abel"] = 2; mymap["jose"] = 1;  myhashmap["lucas"] = 1; myhashmap["abel"] = 2; myhashmap["jose"] = 1;  for(map<string, int>::iterator = mymap.begin(); != mymap.end(); it++){     cout << it->first << " " << it->second << endl; }  cout << endl;  for(hash_map<string, int>::iterator = myhashmap.begin(); != myhashmap.end(); it++){     cout << it->first << " " << it->second << endl; } 

but both results were:

abel 2 jose 1 lucas 1 

why hash_map gave me ordered result?

there no order guarantee in hash_map - means can store results in any order, depending on implementation.


Comments

Popular posts from this blog

javascript - AngularJS custom datepicker directive -

javascript - jQuery date picker - Disable dates after the selection from the first date picker -