some more solves

This commit is contained in:
2025-05-10 16:10:00 +03:00
parent 0cb745c9a1
commit 1924ca48db
11 changed files with 219 additions and 54 deletions
+26
View File
@@ -0,0 +1,26 @@
#include <iostream>
#include <vector>
#include <functional>
template <typename It, typename F>
void myapply(It first, It last, F f) {
for (It it = first; it != last; ++it) {
f(*it);
}
return;
}
template <typename It, typename Pred>
std::vector<std::reference_wrapper<typename std::iterator_traits<It>::value_type>> myfilter2(It first, It last, Pred f) {
std::vector<std::reference_wrapper<typename std::iterator_traits<It>::value_type>> result;
for (It it = first; it != last; ++it) {
if (f(*it)) {
result.push_back(std::ref(*it));
}
}
return result;
}
+16
View File
@@ -0,0 +1,16 @@
#include <set>
template <typename It1, typename It2>
It2 myremove(It1 first1, It1 last1, It2 first2, It2 last2) {
std::set to_remove(first1, last1);
It2 result = first2;
for (It2 it = first2; it != last2; ++it) {
if (to_remove.find(std::distance(first2, it)) == to_remove.end()) {
std::iter_swap(result, it);
++result;
}
}
return result;
}