diff options
author | luxaeterna <luxaeterna@yandex-team.ru> | 2022-02-10 16:50:14 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:50:14 +0300 |
commit | 5014e8b2e7e17987c50a1b761cee7447f22e006c (patch) | |
tree | 5d5cb817648f650d76cf1076100726fd9b8448e8 /util/generic | |
parent | 2c76d348a3be51f0875ddeaad6b2ccda604dee0f (diff) | |
download | ydb-5014e8b2e7e17987c50a1b761cee7447f22e006c.tar.gz |
Restoring authorship annotation for <luxaeterna@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'util/generic')
-rw-r--r-- | util/generic/algorithm.h | 10 | ||||
-rw-r--r-- | util/generic/algorithm_ut.cpp | 28 |
2 files changed, 19 insertions, 19 deletions
diff --git a/util/generic/algorithm.h b/util/generic/algorithm.h index 7e73f03f82..badfb88993 100644 --- a/util/generic/algorithm.h +++ b/util/generic/algorithm.h @@ -724,11 +724,11 @@ bool IsSorted(ForwardIt begin, ForwardIt end, Compare comp) { return std::is_sorted(begin, end, comp); } -template <class TIterator, typename TGetKey> -bool IsSortedBy(TIterator begin, TIterator end, const TGetKey& getKey) { - return IsSorted(begin, end, [&](auto&& left, auto&& right) { return getKey(left) < getKey(right); }); -} - +template <class TIterator, typename TGetKey> +bool IsSortedBy(TIterator begin, TIterator end, const TGetKey& getKey) { + return IsSorted(begin, end, [&](auto&& left, auto&& right) { return getKey(left) < getKey(right); }); +} + template <class It, class Val> void Iota(It begin, It end, Val val) { std::iota(begin, end, val); diff --git a/util/generic/algorithm_ut.cpp b/util/generic/algorithm_ut.cpp index 71f6a3da8f..8d732fcc0c 100644 --- a/util/generic/algorithm_ut.cpp +++ b/util/generic/algorithm_ut.cpp @@ -431,20 +431,20 @@ Y_UNIT_TEST_SUITE(TAlgorithm) { UNIT_ASSERT_VALUES_EQUAL(IsSorted(v2.begin(), v2.end(), TGreater<int>()), false); } - Y_UNIT_TEST(IsSortedByTest) { - TVector<int> v0; - UNIT_ASSERT_VALUES_EQUAL(IsSortedBy(v0.begin(), v0.end(), std::negate<int>()), true); - - TVector<int> v1 = {1}; - UNIT_ASSERT_VALUES_EQUAL(IsSortedBy(v1.begin(), v1.end(), std::negate<int>()), true); - - TVector<int> v2 = {8, 7, 6, 6, 5, 5, 5, 4, 3, 2, 1}; - UNIT_ASSERT_VALUES_EQUAL(IsSortedBy(v2.begin(), v2.end(), std::negate<int>()), true); - - TVector<int> v3 = {1, 2, 1}; - UNIT_ASSERT_VALUES_EQUAL(IsSortedBy(v3.begin(), v3.end(), std::negate<int>()), false); - } - + Y_UNIT_TEST(IsSortedByTest) { + TVector<int> v0; + UNIT_ASSERT_VALUES_EQUAL(IsSortedBy(v0.begin(), v0.end(), std::negate<int>()), true); + + TVector<int> v1 = {1}; + UNIT_ASSERT_VALUES_EQUAL(IsSortedBy(v1.begin(), v1.end(), std::negate<int>()), true); + + TVector<int> v2 = {8, 7, 6, 6, 5, 5, 5, 4, 3, 2, 1}; + UNIT_ASSERT_VALUES_EQUAL(IsSortedBy(v2.begin(), v2.end(), std::negate<int>()), true); + + TVector<int> v3 = {1, 2, 1}; + UNIT_ASSERT_VALUES_EQUAL(IsSortedBy(v3.begin(), v3.end(), std::negate<int>()), false); + } + Y_UNIT_TEST(SortTestTwoIterators) { TVector<int> collection = {10, 2, 7}; Sort(collection.begin(), collection.end()); |