#include <bits/stdc++.h>
using
namespace
std;
unordered_multimap<
char
,
char
> merge(unordered_multimap<
char
,
char
> a,
unordered_multimap<
char
,
char
> b)
{
unordered_multimap<
char
,
char
> temp(a);
temp.insert(b.begin(), b.end());
return
temp;
}
int
main()
{
unordered_multimap<
char
,
char
> sample1, sample2, sample3;
sample1.insert({
'a'
,
'A'
});
sample1.insert({
'g'
,
'G'
});
sample2.insert({
'b'
,
'B'
});
sample2.insert({
'c'
,
'C'
});
sample2.insert({
'd'
,
'D'
});
cout <<
"Key and Elements of Sample1 are: "
;
for
(
auto
it = sample1.begin(); it != sample1.end(); it++) {
cout <<
"{"
<< it->first <<
", "
<< it->second <<
"} "
;
}
cout <<
"\nKey and Elements of Sample2 are: "
;
for
(
auto
it = sample2.begin(); it != sample2.end(); it++) {
cout <<
"{"
<< it->first <<
", "
<< it->second <<
"} "
;
}
sample3 = merge(sample1, sample2);
sample1 = sample3;
cout <<
"\n\nKey and Elements of Sample1 are: "
;
for
(
auto
it = sample1.begin(); it != sample1.end(); it++) {
cout <<
"{"
<< it->first <<
", "
<< it->second <<
"} "
;
}
return
0;
}