aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoravatar <avatar@yandex-team.ru>2022-02-10 16:50:10 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:50:10 +0300
commite21d5670f181bded7a3222fe235c79bea9d9f378 (patch)
treee7d9da854fe0f8f38dad6be2866c4bc8a7f99847
parentaed1c1c7782eb0a0536e5b25bbed950b397e0ac8 (diff)
downloadydb-e21d5670f181bded7a3222fe235c79bea9d9f378.tar.gz
Restoring authorship annotation for <avatar@yandex-team.ru>. Commit 1 of 2.
-rw-r--r--library/cpp/containers/top_keeper/top_keeper.h16
-rw-r--r--library/cpp/containers/top_keeper/top_keeper/top_keeper.h16
-rw-r--r--library/cpp/containers/top_keeper/top_keeper/ut/top_keeper_ut.cpp78
-rw-r--r--library/cpp/containers/top_keeper/ut/top_keeper_ut.cpp78
-rw-r--r--library/cpp/deprecated/split/delim_string_iter_ut.cpp38
5 files changed, 113 insertions, 113 deletions
diff --git a/library/cpp/containers/top_keeper/top_keeper.h b/library/cpp/containers/top_keeper/top_keeper.h
index 2f282b5a9e..a07b567ea3 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<T, Alloc> 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<UT>(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 2f282b5a9e..a07b567ea3 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<T, Alloc> 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<UT>(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 a938279025..666d0a8297 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 <library/cpp/containers/limited_heap/limited_heap.h>
#include <library/cpp/containers/top_keeper/top_keeper.h>
#include <library/cpp/testing/unittest/registar.h>
-#include <util/random/random.h>
+#include <util/random/random.h>
static ui32 seed = 3;
ui32 Rnd() {
@@ -158,50 +158,50 @@ Y_UNIT_TEST_SUITE(TTopKeeperTest) {
h2.Pop();
}
}
-
+
Y_UNIT_TEST(PreRegressionTest) {
- typedef std::pair<float, unsigned int> TElementType;
-
- const size_t randomTriesCount = 128;
+ typedef std::pair<float, unsigned int> TElementType;
+
+ const size_t randomTriesCount = 128;
for (size_t i1 = 0; i1 < randomTriesCount; ++i1) {
- const size_t desiredElementsCount = RandomNumber<size_t>(5) + 1;
- TLimitedHeap<TElementType> h1(desiredElementsCount);
- TTopKeeper<TElementType> h2(desiredElementsCount);
-
- const size_t elementsToInsert = RandomNumber<size_t>(10) + desiredElementsCount;
- UNIT_ASSERT_C(desiredElementsCount <= elementsToInsert, "Test internal invariant is broken");
+ const size_t desiredElementsCount = RandomNumber<size_t>(5) + 1;
+ TLimitedHeap<TElementType> h1(desiredElementsCount);
+ TTopKeeper<TElementType> h2(desiredElementsCount);
+
+ const size_t elementsToInsert = RandomNumber<size_t>(10) + desiredElementsCount;
+ UNIT_ASSERT_C(desiredElementsCount <= elementsToInsert, "Test internal invariant is broken");
for (size_t i2 = 0; i2 < elementsToInsert; ++i2) {
- const auto f = RandomNumber<float>();
- const auto id = RandomNumber<unsigned int>();
-
- 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<float>();
+ const auto id = RandomNumber<unsigned int>();
+
+ 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<float>;
+ using TKeeper = TTopKeeper<float>;
TVector<TKeeper> v(2, TKeeper(200));
- auto& k = v[1];
- for (size_t i = 0; i < 100; ++i) {
- k.Insert(RandomNumber<float>());
- }
- k.Finalize();
- }
+ auto& k = v[1];
+ for (size_t i = 0; i < 100; ++i) {
+ k.Insert(RandomNumber<float>());
+ }
+ k.Finalize();
+ }
Y_UNIT_TEST(ExtractTest) {
TTopKeeper<size_t> 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 a938279025..666d0a8297 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 <library/cpp/containers/limited_heap/limited_heap.h>
#include <library/cpp/containers/top_keeper/top_keeper.h>
#include <library/cpp/testing/unittest/registar.h>
-#include <util/random/random.h>
+#include <util/random/random.h>
static ui32 seed = 3;
ui32 Rnd() {
@@ -158,50 +158,50 @@ Y_UNIT_TEST_SUITE(TTopKeeperTest) {
h2.Pop();
}
}
-
+
Y_UNIT_TEST(PreRegressionTest) {
- typedef std::pair<float, unsigned int> TElementType;
-
- const size_t randomTriesCount = 128;
+ typedef std::pair<float, unsigned int> TElementType;
+
+ const size_t randomTriesCount = 128;
for (size_t i1 = 0; i1 < randomTriesCount; ++i1) {
- const size_t desiredElementsCount = RandomNumber<size_t>(5) + 1;
- TLimitedHeap<TElementType> h1(desiredElementsCount);
- TTopKeeper<TElementType> h2(desiredElementsCount);
-
- const size_t elementsToInsert = RandomNumber<size_t>(10) + desiredElementsCount;
- UNIT_ASSERT_C(desiredElementsCount <= elementsToInsert, "Test internal invariant is broken");
+ const size_t desiredElementsCount = RandomNumber<size_t>(5) + 1;
+ TLimitedHeap<TElementType> h1(desiredElementsCount);
+ TTopKeeper<TElementType> h2(desiredElementsCount);
+
+ const size_t elementsToInsert = RandomNumber<size_t>(10) + desiredElementsCount;
+ UNIT_ASSERT_C(desiredElementsCount <= elementsToInsert, "Test internal invariant is broken");
for (size_t i2 = 0; i2 < elementsToInsert; ++i2) {
- const auto f = RandomNumber<float>();
- const auto id = RandomNumber<unsigned int>();
-
- 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<float>();
+ const auto id = RandomNumber<unsigned int>();
+
+ 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<float>;
+ using TKeeper = TTopKeeper<float>;
TVector<TKeeper> v(2, TKeeper(200));
- auto& k = v[1];
- for (size_t i = 0; i < 100; ++i) {
- k.Insert(RandomNumber<float>());
- }
- k.Finalize();
- }
+ auto& k = v[1];
+ for (size_t i = 0; i < 100; ++i) {
+ k.Insert(RandomNumber<float>());
+ }
+ k.Finalize();
+ }
Y_UNIT_TEST(ExtractTest) {
TTopKeeper<size_t> 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 18a8b2a160..eb88fa927e 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 <util/generic/vector.h>
+#include <util/generic/vector.h>
#include <library/cpp/testing/unittest/registar.h>
-
+
/// 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<TString>& 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,