multiset c 2b 2b

Solutions on MaxInterview for multiset c 2b 2b by the best coders in the world

showing results for - "multiset c 2b 2b"
Valeria
20 Mar 2019
1< Multisets > A multiset is a set that can have several copies of the same value. 
2 C++ has the structures multiset and unordered_multiset that resemble set and
3unordered_set. 
4  
5  multiset<int> s;
6  s.insert(2);
7  s.insert(2);
8  s.insert(2);
9  cout << s.count(2) << "\n"; // 3
10
11- Erase removes all copies of a value from a multiset:
12     s.erase(2);
13     cout << s.count(2) << "\n"; // 0
14
15- Erase only one element with value 2
16     s.erase(s.find(2));
17     cout << s.count(2) << "\n"; // 2