-
Notifications
You must be signed in to change notification settings - Fork 0
/
multiMap.cpp
50 lines (38 loc) · 1.17 KB
/
multiMap.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
// Last sanity check: 2020-05-18
//
// main.cpp
// Exer
//
// Created by Alex Seceleanu on 4/9/18.
// Copyright © 2018 Alex Seceleanu. All rights reserved.
//
#include <stdio.h>
#include <map>
#include <iostream>
using namespace std;
int main()
{
multimap<int, string> look;
look.insert(make_pair(30, "Mih"));
look.insert(make_pair(10, "Ale"));
look.insert(make_pair(30, "Bob"));
look.insert(make_pair(20, "Ion"));
look.insert(make_pair(40, "Ana"));
for (multimap<int, string>::iterator it = look.begin(); it!=look.end(); it++)
{
cout << it -> first << " : " << it -> second << endl;
}
cout<<endl << "Searching for key 30:"<< endl ;
for (multimap<int, string>::iterator it = look.find(30); it!=look.end(); it++)
{
cout << it -> first << " : " << it -> second << endl;
}
cout <<endl <<"Correctly searching for key 30:"<< endl;
//pair<multimap<int, string>::iterator, multimap<int, string>::iterator>
auto its = look.equal_range(30);
for (auto it = its.first; it!=its.second; it++)
{
cout << it -> first << " : " << it -> second << endl;
}
return 0;
}