diff options
author | Nikita Petrenko <npetrenko97@gmail.com> | 2022-02-10 16:50:57 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:50:57 +0300 |
commit | fd3f62e99d2990dd93788742aaf6a9bd5cb4d5a3 (patch) | |
tree | 5d5cb817648f650d76cf1076100726fd9b8448e8 /library/cpp/iterator | |
parent | aa72317474c8df5627f69271ae16f4237e5d3612 (diff) | |
download | ydb-fd3f62e99d2990dd93788742aaf6a9bd5cb4d5a3.tar.gz |
Restoring authorship annotation for Nikita Petrenko <npetrenko97@gmail.com>. Commit 2 of 2.
Diffstat (limited to 'library/cpp/iterator')
-rw-r--r-- | library/cpp/iterator/ut/ya.make | 2 | ||||
-rw-r--r-- | library/cpp/iterator/ut/zip_ut.cpp | 56 | ||||
-rw-r--r-- | library/cpp/iterator/zip.h | 16 |
3 files changed, 37 insertions, 37 deletions
diff --git a/library/cpp/iterator/ut/ya.make b/library/cpp/iterator/ut/ya.make index 058253149f..601e5663b9 100644 --- a/library/cpp/iterator/ut/ya.make +++ b/library/cpp/iterator/ut/ya.make @@ -12,7 +12,7 @@ SRCS( iterate_keys_ut.cpp iterate_values_ut.cpp mapped_ut.cpp - zip_ut.cpp + zip_ut.cpp ) END() diff --git a/library/cpp/iterator/ut/zip_ut.cpp b/library/cpp/iterator/ut/zip_ut.cpp index 3ef45d30dc..68d496515c 100644 --- a/library/cpp/iterator/ut/zip_ut.cpp +++ b/library/cpp/iterator/ut/zip_ut.cpp @@ -1,28 +1,28 @@ -#include <library/cpp/iterator/zip.h> - -#include <library/cpp/testing/gtest/gtest.h> - -#include <util/generic/vector.h> - -TEST(TIterator, ZipSimplePostIncrement) { - TVector<int> left{1, 2, 3}; - TVector<int> right{4, 5, 6}; - - auto zipped = Zip(left, right); - auto cur = zipped.begin(); - auto last = zipped.end(); - - { - auto first = *(cur++); - EXPECT_EQ(std::get<0>(first), 1); - EXPECT_EQ(std::get<1>(first), 4); - } - { - auto second = *(cur++); - EXPECT_EQ(std::get<0>(second), 2); - EXPECT_EQ(std::get<1>(second), 5); - } - - EXPECT_EQ(std::next(cur), last); -} - +#include <library/cpp/iterator/zip.h> + +#include <library/cpp/testing/gtest/gtest.h> + +#include <util/generic/vector.h> + +TEST(TIterator, ZipSimplePostIncrement) { + TVector<int> left{1, 2, 3}; + TVector<int> right{4, 5, 6}; + + auto zipped = Zip(left, right); + auto cur = zipped.begin(); + auto last = zipped.end(); + + { + auto first = *(cur++); + EXPECT_EQ(std::get<0>(first), 1); + EXPECT_EQ(std::get<1>(first), 4); + } + { + auto second = *(cur++); + EXPECT_EQ(std::get<0>(second), 2); + EXPECT_EQ(std::get<1>(second), 5); + } + + EXPECT_EQ(std::next(cur), last); +} + diff --git a/library/cpp/iterator/zip.h b/library/cpp/iterator/zip.h index 51c7116e38..ac12ed35fe 100644 --- a/library/cpp/iterator/zip.h +++ b/library/cpp/iterator/zip.h @@ -58,16 +58,16 @@ namespace NPrivate { TValue operator*() const { return {*std::get<I>(Iterators_)...}; } - - TIterator& operator++() { + + TIterator& operator++() { (++std::get<I>(Iterators_), ...); - return *this; + return *this; + } + + TIterator operator++(int) { + return TIterator{TIteratorState{std::get<I>(Iterators_)++...}}; } - - TIterator operator++(int) { - return TIterator{TIteratorState{std::get<I>(Iterators_)++...}}; - } - + bool operator!=(const TSentinel& other) const { if constexpr (LimitByFirstContainer) { return std::get<0>(Iterators_) != std::get<0>(other.Iterators_); |