1
0
Fork 0

Update include.hh

Signed-off-by: subcrip <contact@subc.rip>
This commit is contained in:
subcrip 2024-05-13 15:14:55 +08:00
parent 06b229bab2
commit ea13b6d5ea
1 changed files with 5 additions and 4 deletions

View File

@ -409,10 +409,11 @@ vector<pair<T, U>> zip(Iterator_T a_first, Iterator_T a_last, Iterator_U b_first
template <typename T, typename U, typename Iterator_T, typename Iterator_U> template <typename T, typename U, typename Iterator_T, typename Iterator_U>
vector<pair<T, U>> zip_n(Iterator_T a_first, Iterator_U b_first, size_t n) { vector<pair<T, U>> zip_n(Iterator_T a_first, Iterator_U b_first, size_t n) {
vector<pair<T, U>> res; vector<pair<T, U>> res;
auto a_it = a_first; if (n > 0) {
auto b_it = b_first; res.emplace_back(*a_first, *b_first);
for (; n != 0; ++a_it, ++b_it, --n) { for (size_t i = 1; i != n; ++i) {
res.emplace_back(*a_it, *b_it); res.emplace_back(*++a_first, *++b_first);
}
} }
return res; return res;
} }