-
Notifications
You must be signed in to change notification settings - Fork 0
/
multi_set.cpp
90 lines (69 loc) · 1.5 KB
/
multi_set.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#include<iostream>
#include<conio.h>
#include<set>
using namespace std;
int main()
{
multiset<int>ms,ms2;
ms.insert(1);
ms.insert(4);
ms.insert(3);
ms.insert(3);
ms.insert(5);
ms.insert(5);
ms.insert(6);
ms.emplace(7);
ms2.emplace(8);
ms2.emplace(9);
ms2.emplace(10);
multiset<int> :: iterator it;
for(it= ms.begin(); it!= ms.end(); it++)
{
cout<< *it << " ";
}
cout<<endl;
for(auto it1 : ms)cout<< it1 << " ";
cout<< endl;
cout<< ms.size() <<endl;
cout<< ms.max_size() <<endl;
if(ms.empty())cout<< "Empty" << " ";
else cout<< "Not Empty" <<endl;
//ms.clear();
for(auto it : ms)cout<< it << " ";
cout<<endl;
it= ms.begin();
advance(it,3);
ms.erase(it);
for(auto it : ms)cout<< it << " ";
cout<<endl;
auto it2= ms.find(2);
if(it==ms.end())
{
cout<< "Not Find"<<endl;
}
else
cout<< "Find"<<endl;
cout<< ms.count(50) <<endl;
auto it3= ms.lower_bound(3);
for(auto it4=it3; it4!=ms.end(); it4++)
{
cout<< *it4 << " ";
}
cout<< endl;
cout<< *it3 << endl;
auto it5= ms.upper_bound(2);
for(auto it6= it5; it6!=ms.end(); it6++)
{
cout<< *it6 <<" ";
}
cout<< *it5 <<endl;
ms2= ms;
for(auto it7 : ms2)cout<< it7 << " ";
cout<<endl;
for(auto it8 : ms2)cout<< it8 << " ";
cout<<endl;
ms.swap(ms2);
for(auto it8 : ms)cout<< it8 << " ";
cout<<endl;
getch();
}