22.允许重复的容器(unordered_multiset)

Posted 喵小喵~

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了22.允许重复的容器(unordered_multiset)相关的知识,希望对你有一定的参考价值。

 1 #include <string>
 2 #include <iostream>
 3 #include <unordered_set>
 4 using namespace std;
 5 
 6 
 7 void main()
 8 {
 9     unordered_multiset<string> myset{ "pig", "pig", "pig" ,"chicken"};
10     /*for (auto i : myset)
11     {
12         cout << i << endl;
13     }*/
14 
15     auto it = myset.equal_range("pig");
16     
17     //输出所有重复数据
18     //it.first链表的起点 it.second链表的终点
19     for (auto ib = it.first, ie = it.second; ib != ie; ib++)
20     {
21         cout << *it.first << endl;
22     }
23 
24     cin.get();
25 }

 

以上是关于22.允许重复的容器(unordered_multiset)的主要内容,如果未能解决你的问题,请参考以下文章