C++:无序容器

无序容器存储的也是键值对元素,他的底层是哈希表,正如他的名称一样,他并不像关联容器那样默认作升序排序

undered_map:无序键不重

undered_multimap:无序键可重

undered_set:与set相比无序

undered_multiset:与undered_set相比,元素可重复

#include
#include
using namespace std;



int main()
{
	//unordered_mapump;
	unordered_multimapump;//[]就不能使了
	//ump[200] = 'A';
	//ump[100] = 'B';
	//ump[300] = 'C';

	unordered_map::iterator ite = ump.begin();
	while (ite != ump.end())
	{
		cout << ite->first << " " << ite->second << endl;
		ite++;
	}




	return 0;
}

你可能感兴趣的:(c++,算法,数据结构)