C++:无序容器
无序容器存储的也是键值对元素,他的底层是哈希表,正如他的名称一样,他并不像关联容器那样默认作升序排序
undered_map:无序键不重
undered_multimap:无序键可重
undered_set:与set相比无序
undered_multiset:与undered_set相比,元素可重复
#include<iostream>
#include<unordered_map>
using namespace std;int main()
{//unordered_map<int, char>ump;unordered_multimap<int, char>ump;//[]就不能使了//ump[200] = 'A';//ump[100] = 'B';//ump[300] = 'C';unordered_map<int, char>::iterator ite = ump.begin();while (ite != ump.end()){cout << ite->first << " " << ite->second << endl;ite++;}return 0;
}