From 7cba2edf1dbe4bc03ee23552d0a418bf48eb3a13 Mon Sep 17 00:00:00 2001 From: avatar Date: Thu, 10 Feb 2022 16:50:10 +0300 Subject: Restoring authorship annotation for . Commit 2 of 2. --- library/cpp/containers/top_keeper/top_keeper.h | 16 ++--- .../containers/top_keeper/top_keeper/top_keeper.h | 16 ++--- .../top_keeper/top_keeper/ut/top_keeper_ut.cpp | 78 +++++++++++----------- .../cpp/containers/top_keeper/ut/top_keeper_ut.cpp | 78 +++++++++++----------- .../cpp/deprecated/split/delim_string_iter_ut.cpp | 38 +++++------ 5 files changed, 113 insertions(+), 113 deletions(-) (limited to 'library/cpp') diff --git a/library/cpp/containers/top_keeper/top_keeper.h b/library/cpp/containers/top_keeper/top_keeper.h index a07b567ea33..2f282b5a9e1 100644 --- a/library/cpp/containers/top_keeper/top_keeper.h +++ b/library/cpp/containers/top_keeper/top_keeper.h @@ -13,7 +13,7 @@ private: TVector Internal; size_t HalfMaxSize; TComparator Comparer; - size_t MinElementIndex; + size_t MinElementIndex; private: void Reserve() { @@ -27,12 +27,12 @@ private: } if (Internal.size() < HalfMaxSize) { - if (Internal.empty() || Comparer(Internal[MinElementIndex], value)) { - MinElementIndex = Internal.size(); + if (Internal.empty() || Comparer(Internal[MinElementIndex], value)) { + MinElementIndex = Internal.size(); Internal.push_back(std::forward(value)); return true; } - } else if (!Comparer(value, Internal[MinElementIndex])) { + } else if (!Comparer(value, Internal[MinElementIndex])) { return false; } @@ -75,9 +75,9 @@ private: if (Y_LIKELY(Internal.size() >= HalfMaxSize)) { NthElement(Internal.begin(), Internal.begin() + HalfMaxSize - 1, Internal.end(), Comparer); Internal.erase(Internal.begin() + HalfMaxSize, Internal.end()); - - //we should update MinElementIndex cause we just altered Internal - MinElementIndex = HalfMaxSize - 1; + + //we should update MinElementIndex cause we just altered Internal + MinElementIndex = HalfMaxSize - 1; } } @@ -127,7 +127,7 @@ private: void Reset() { Internal.clear(); - //MinElementIndex will reset itself when we start adding new values + //MinElementIndex will reset itself when we start adding new values } }; diff --git a/library/cpp/containers/top_keeper/top_keeper/top_keeper.h b/library/cpp/containers/top_keeper/top_keeper/top_keeper.h index a07b567ea33..2f282b5a9e1 100644 --- a/library/cpp/containers/top_keeper/top_keeper/top_keeper.h +++ b/library/cpp/containers/top_keeper/top_keeper/top_keeper.h @@ -13,7 +13,7 @@ private: TVector Internal; size_t HalfMaxSize; TComparator Comparer; - size_t MinElementIndex; + size_t MinElementIndex; private: void Reserve() { @@ -27,12 +27,12 @@ private: } if (Internal.size() < HalfMaxSize) { - if (Internal.empty() || Comparer(Internal[MinElementIndex], value)) { - MinElementIndex = Internal.size(); + if (Internal.empty() || Comparer(Internal[MinElementIndex], value)) { + MinElementIndex = Internal.size(); Internal.push_back(std::forward(value)); return true; } - } else if (!Comparer(value, Internal[MinElementIndex])) { + } else if (!Comparer(value, Internal[MinElementIndex])) { return false; } @@ -75,9 +75,9 @@ private: if (Y_LIKELY(Internal.size() >= HalfMaxSize)) { NthElement(Internal.begin(), Internal.begin() + HalfMaxSize - 1, Internal.end(), Comparer); Internal.erase(Internal.begin() + HalfMaxSize, Internal.end()); - - //we should update MinElementIndex cause we just altered Internal - MinElementIndex = HalfMaxSize - 1; + + //we should update MinElementIndex cause we just altered Internal + MinElementIndex = HalfMaxSize - 1; } } @@ -127,7 +127,7 @@ private: void Reset() { Internal.clear(); - //MinElementIndex will reset itself when we start adding new values + //MinElementIndex will reset itself when we start adding new values } }; diff --git a/library/cpp/containers/top_keeper/top_keeper/ut/top_keeper_ut.cpp b/library/cpp/containers/top_keeper/top_keeper/ut/top_keeper_ut.cpp index 666d0a82975..a938279025d 100644 --- a/library/cpp/containers/top_keeper/top_keeper/ut/top_keeper_ut.cpp +++ b/library/cpp/containers/top_keeper/top_keeper/ut/top_keeper_ut.cpp @@ -1,7 +1,7 @@ #include #include #include -#include +#include static ui32 seed = 3; ui32 Rnd() { @@ -158,50 +158,50 @@ Y_UNIT_TEST_SUITE(TTopKeeperTest) { h2.Pop(); } } - + Y_UNIT_TEST(PreRegressionTest) { - typedef std::pair TElementType; - - const size_t randomTriesCount = 128; + typedef std::pair TElementType; + + const size_t randomTriesCount = 128; for (size_t i1 = 0; i1 < randomTriesCount; ++i1) { - const size_t desiredElementsCount = RandomNumber(5) + 1; - TLimitedHeap h1(desiredElementsCount); - TTopKeeper h2(desiredElementsCount); - - const size_t elementsToInsert = RandomNumber(10) + desiredElementsCount; - UNIT_ASSERT_C(desiredElementsCount <= elementsToInsert, "Test internal invariant is broken"); + const size_t desiredElementsCount = RandomNumber(5) + 1; + TLimitedHeap h1(desiredElementsCount); + TTopKeeper h2(desiredElementsCount); + + const size_t elementsToInsert = RandomNumber(10) + desiredElementsCount; + UNIT_ASSERT_C(desiredElementsCount <= elementsToInsert, "Test internal invariant is broken"); for (size_t i2 = 0; i2 < elementsToInsert; ++i2) { - const auto f = RandomNumber(); - const auto id = RandomNumber(); - - h1.Insert(TElementType(f, id)); - h2.Insert(TElementType(f, id)); - } - - h2.Finalize(); - - //we inserted enough elements to guarantee this outcome - UNIT_ASSERT_EQUAL(h1.GetSize(), desiredElementsCount); - UNIT_ASSERT_EQUAL(h2.GetSize(), desiredElementsCount); - - const auto n = h2.GetSize(); + const auto f = RandomNumber(); + const auto id = RandomNumber(); + + h1.Insert(TElementType(f, id)); + h2.Insert(TElementType(f, id)); + } + + h2.Finalize(); + + //we inserted enough elements to guarantee this outcome + UNIT_ASSERT_EQUAL(h1.GetSize(), desiredElementsCount); + UNIT_ASSERT_EQUAL(h2.GetSize(), desiredElementsCount); + + const auto n = h2.GetSize(); for (size_t i3 = 0; i3 < n; ++i3) { - UNIT_ASSERT_EQUAL(h1.GetMin(), h2.GetNext()); - h1.PopMin(); - h2.Pop(); - } - } - } - + UNIT_ASSERT_EQUAL(h1.GetMin(), h2.GetNext()); + h1.PopMin(); + h2.Pop(); + } + } + } + Y_UNIT_TEST(CopyKeeperRegressionCase) { - using TKeeper = TTopKeeper; + using TKeeper = TTopKeeper; TVector v(2, TKeeper(200)); - auto& k = v[1]; - for (size_t i = 0; i < 100; ++i) { - k.Insert(RandomNumber()); - } - k.Finalize(); - } + auto& k = v[1]; + for (size_t i = 0; i < 100; ++i) { + k.Insert(RandomNumber()); + } + k.Finalize(); + } Y_UNIT_TEST(ExtractTest) { TTopKeeper keeper(100); diff --git a/library/cpp/containers/top_keeper/ut/top_keeper_ut.cpp b/library/cpp/containers/top_keeper/ut/top_keeper_ut.cpp index 666d0a82975..a938279025d 100644 --- a/library/cpp/containers/top_keeper/ut/top_keeper_ut.cpp +++ b/library/cpp/containers/top_keeper/ut/top_keeper_ut.cpp @@ -1,7 +1,7 @@ #include #include #include -#include +#include static ui32 seed = 3; ui32 Rnd() { @@ -158,50 +158,50 @@ Y_UNIT_TEST_SUITE(TTopKeeperTest) { h2.Pop(); } } - + Y_UNIT_TEST(PreRegressionTest) { - typedef std::pair TElementType; - - const size_t randomTriesCount = 128; + typedef std::pair TElementType; + + const size_t randomTriesCount = 128; for (size_t i1 = 0; i1 < randomTriesCount; ++i1) { - const size_t desiredElementsCount = RandomNumber(5) + 1; - TLimitedHeap h1(desiredElementsCount); - TTopKeeper h2(desiredElementsCount); - - const size_t elementsToInsert = RandomNumber(10) + desiredElementsCount; - UNIT_ASSERT_C(desiredElementsCount <= elementsToInsert, "Test internal invariant is broken"); + const size_t desiredElementsCount = RandomNumber(5) + 1; + TLimitedHeap h1(desiredElementsCount); + TTopKeeper h2(desiredElementsCount); + + const size_t elementsToInsert = RandomNumber(10) + desiredElementsCount; + UNIT_ASSERT_C(desiredElementsCount <= elementsToInsert, "Test internal invariant is broken"); for (size_t i2 = 0; i2 < elementsToInsert; ++i2) { - const auto f = RandomNumber(); - const auto id = RandomNumber(); - - h1.Insert(TElementType(f, id)); - h2.Insert(TElementType(f, id)); - } - - h2.Finalize(); - - //we inserted enough elements to guarantee this outcome - UNIT_ASSERT_EQUAL(h1.GetSize(), desiredElementsCount); - UNIT_ASSERT_EQUAL(h2.GetSize(), desiredElementsCount); - - const auto n = h2.GetSize(); + const auto f = RandomNumber(); + const auto id = RandomNumber(); + + h1.Insert(TElementType(f, id)); + h2.Insert(TElementType(f, id)); + } + + h2.Finalize(); + + //we inserted enough elements to guarantee this outcome + UNIT_ASSERT_EQUAL(h1.GetSize(), desiredElementsCount); + UNIT_ASSERT_EQUAL(h2.GetSize(), desiredElementsCount); + + const auto n = h2.GetSize(); for (size_t i3 = 0; i3 < n; ++i3) { - UNIT_ASSERT_EQUAL(h1.GetMin(), h2.GetNext()); - h1.PopMin(); - h2.Pop(); - } - } - } - + UNIT_ASSERT_EQUAL(h1.GetMin(), h2.GetNext()); + h1.PopMin(); + h2.Pop(); + } + } + } + Y_UNIT_TEST(CopyKeeperRegressionCase) { - using TKeeper = TTopKeeper; + using TKeeper = TTopKeeper; TVector v(2, TKeeper(200)); - auto& k = v[1]; - for (size_t i = 0; i < 100; ++i) { - k.Insert(RandomNumber()); - } - k.Finalize(); - } + auto& k = v[1]; + for (size_t i = 0; i < 100; ++i) { + k.Insert(RandomNumber()); + } + k.Finalize(); + } Y_UNIT_TEST(ExtractTest) { TTopKeeper keeper(100); diff --git a/library/cpp/deprecated/split/delim_string_iter_ut.cpp b/library/cpp/deprecated/split/delim_string_iter_ut.cpp index eb88fa927e2..18a8b2a1604 100644 --- a/library/cpp/deprecated/split/delim_string_iter_ut.cpp +++ b/library/cpp/deprecated/split/delim_string_iter_ut.cpp @@ -1,35 +1,35 @@ #include "delim_string_iter.h" -#include +#include #include - + /// Test that TDelimStringIter build on top of given string and delimeter will produce expected sequence static void AssertStringSplit(const TString& str, const TString& delim, const TVector& expected) { TDelimStringIter it(str, delim); - - // test iterator invariants - for (const auto& expectedString : expected) { - UNIT_ASSERT(it.Valid()); + + // test iterator invariants + for (const auto& expectedString : expected) { + UNIT_ASSERT(it.Valid()); UNIT_ASSERT(bool(it)); UNIT_ASSERT_STRINGS_EQUAL(it->ToString(), expectedString); - ++it; - } - UNIT_ASSERT(!it.Valid()); -}; - + ++it; + } + UNIT_ASSERT(!it.Valid()); +}; + Y_UNIT_TEST_SUITE(TDelimStrokaIterTestSuite) { Y_UNIT_TEST(SingleCharacterAsDelimiter) { - AssertStringSplit( + AssertStringSplit( "Hello words!", " ", {"Hello", "words!"}); - } - + } + Y_UNIT_TEST(MultipleCharactersAsDelimiter) { - AssertStringSplit( + AssertStringSplit( "0, 1, 1, 2, 3, 5, 8, 13, 21, 34", "1, ", {"0, ", "", "2, 3, 5, 8, 13, 2", "34"}); - } - + } + Y_UNIT_TEST(NoDelimitersPresent) { AssertStringSplit("This string could be yours", "\t", {"This string could be yours"}); - } + } Y_UNIT_TEST(Cdr) { TDelimStringIter it("a\tc\t", "\t"); @@ -49,7 +49,7 @@ Y_UNIT_TEST_SUITE(TDelimStrokaIterTestSuite) { UNIT_ASSERT_EQUAL(got, expected); } -} +} static void AssertKeyValueStringSplit( const TStringBuf str, -- cgit v1.3