forked from coders-school/stl
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtransform.cpp
More file actions
21 lines (20 loc) · 831 Bytes
/
transform.cpp
File metadata and controls
21 lines (20 loc) · 831 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#include "transform.hpp"
std::map<int, std::string> removeDuplicateAndTranformToMap(
std::list<std::string>& l,
std::deque<int>& d) {
std::sort(d.begin(), d.end());
l.sort([](auto a, auto b) {
return std::lexicographical_compare(
a.begin(), a.end(), b.begin(), b.end(),
[](auto c1, auto c2) { return std::tolower(c1) < std::tolower(c2); });
});
auto it = std::unique(l.begin(), l.end());
auto it2 = std::unique(d.begin(), d.end());
std::map<int, std::string> result;
auto dst1 = std::distance(it, l.begin());
auto dst2 = std::distance(it2, d.begin());
std::transform(l.begin(), it, d.begin(),
std::inserter(result, result.begin()),
[](auto s, auto i) mutable { return std::make_pair(i, s); });
return result;
};