1
0
Fork 0

Update include.hh

Signed-off-by: subcrip <contact@subc.rip>
This commit is contained in:
subcrip 2024-05-18 19:38:06 +08:00
parent bdaf080698
commit 17942dd51f
1 changed files with 4 additions and 1 deletions

View File

@ -429,7 +429,7 @@ vector<pair<T, U>> zip(Iterator_T a_first, Iterator_T a_last, Iterator_U b_first
vector<pair<T, U>> res; vector<pair<T, U>> res;
auto a_it = a_first; auto a_it = a_first;
auto b_it = b_first; auto b_it = b_first;
for (; a_it != a_last and b_it != b_last; ++a_it, ++b_it) { for (; not (a_it == a_last) and not (b_it == b_last); ++a_it, ++b_it) {
res.emplace_back(*a_it, *b_it); res.emplace_back(*a_it, *b_it);
} }
return res; return res;
@ -459,4 +459,7 @@ public:
ArithmeticIterator<T>& operator--() { --value; return *this; } ArithmeticIterator<T>& operator--() { --value; return *this; }
bool operator==(const ArithmeticIterator<T>& rhs) const { return value == rhs.value; } bool operator==(const ArithmeticIterator<T>& rhs) const { return value == rhs.value; }
}; };
template <typename T> vector<pair<int, T>> enumerate(const vector<T>& container) {
return zip<int, T>(ArithmeticIterator<int>(0), ArithmeticIterator<int>(INT_MAX), container.begin(), container.end());
}
///////////////////////////////////////////////////////// /////////////////////////////////////////////////////////