-
Notifications
You must be signed in to change notification settings - Fork 32
Expand file tree
/
Copy path19.4 MSetErase.cpp
More file actions
38 lines (28 loc) · 791 Bytes
/
19.4 MSetErase.cpp
File metadata and controls
38 lines (28 loc) · 791 Bytes
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
#include <set>
#include <iostream>
using namespace std;
template <typename T>
void DisplayContents(const T& Input)
{
for(auto element = Input.cbegin();
element != Input.cend();
++ element)
cout << *element << ' ';
cout << endl;
}
typedef multiset<int> MSETINT;
int main()
{
MSETINT msetInts{ 43, 78, 78, -1, 124 };
cout << "multiset contains " << msetInts.size() << " elements: ";
DisplayContents(msetInts);
cout << "Enter a number to erase from the set: ";
int input = 0;
cin >> input;
cout << "Erasing " << msetInts.count(input);
cout << " instances of value " << input << endl;
msetInts.erase(input);
cout << "multiset now contains " << msetInts.size() << " elements: ";
DisplayContents(msetInts);
return 0;
}