-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
34 lines (27 loc) · 750 Bytes
/
main.cpp
File metadata and controls
34 lines (27 loc) · 750 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
#include <iostream>
#include <vector>
#include <memory>
#include <algorithm>
#include <unordered_set>
using namespace std;
int main()
{
cout << "---No repetition---" << endl;
vector<int> v = {1,2,3,3,4,5,4,5,6,6,8,8,9,10,11,12,12,1,2,4,5,3,2};
for(auto e:v)
cout << e << " ";
cout << endl;
auto myLamb = [] (const vector<int>& v)
{
unordered_set<int> n;
vector<int> r;
for_each(v.begin(),v.end(),[&n](auto e){n.insert(e);});
for_each(n.begin(),n.end(),[&r](auto e){r.push_back(e);});
return make_unique<vector<int>>(r);
};
unique_ptr<vector<int>> ptrVec = myLamb(v);
for(auto e:*ptrVec)
cout << e << " ";
cout << endl;
cout << "---Bye, bye!---" << endl;
}