일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
Tags
- pandas
- c
- box-sizing
- Codility
- 확률
- react
- Prefix Sums
- 백준
- Gap
- SK바이오사이언스
- skt membership
- spring
- grid
- 알고리즘
- c++
- Javascript
- 수학
- 통신사할인
- 상태
- REM
- 포토샵
- 강화학습
- stl
- float
- 소수
- 반응형 웹
- transform
- CSS
- Photoshop
- 미디어 쿼리
Archives
- Today
- Total
sliver__
[Mastering C++ Programming] - Multimap 본문
728x90
- multimap은 multimap 컨테이너가 동일한 키로 여러 값을 저장할 수 있다는 점을 제외하면 정확히 맵과 동일하게 작동합니다.
- 예제 코드는 아래와 같다.
#include <iostream>
#include <map>
#include <vector>
#include <iterator>
#include <algorithm>
using namespace std;
int main() {
multimap< string, long > contacts = {
{ "Jegan", 2232342343 },
{ "Meena", 3243435343 },
{ "Nitesh", 6234324343 },
{ "Sriram", 8932443241 },
{ "Nitesh", 5534327346 }
};
auto pos = contacts.find ( "Nitesh" );
int count = contacts.count( "Nitesh" );
int index = 0;
while ( pos != contacts.end() ) {
cout << "\nMobile number of " << pos->first << " is " <<
pos->second << endl;
pos++;
++index;
if ( index == count )
break;
}
return 0;
}
- 결과는 아래와 같다.
Mobile number of Nitesh is 6234324343
Mobile number of Nitesh is 5534327346
728x90
'CS > C++' 카테고리의 다른 글
[Mastering C++ Programming] - unordered_map (0) | 2022.12.05 |
---|---|
[Mastering C++ Programming] - Unordered set (0) | 2022.12.05 |
[Mastering C++ Programming] - MultiSet (0) | 2022.12.05 |
[Mastering C++ Programming] - Map (0) | 2022.12.05 |
[Mastering C++ Programming] - Set (0) | 2022.12.05 |
Comments