aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/containers/intrusive_rb_tree/rb_tree_ut.cpp
diff options
context:
space:
mode:
authorvavbrs <vavbrs@yandex-team.ru>2022-02-10 16:50:37 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:50:37 +0300
commite457c00835fa6b453dda3392d911fa8a25fd4f37 (patch)
treeba5ee859bfa8875be6f4c37160c5c71b608bde3d /library/cpp/containers/intrusive_rb_tree/rb_tree_ut.cpp
parentf28ae3e2752def3bd0a14422be2a0b22ab434b9c (diff)
downloadydb-e457c00835fa6b453dda3392d911fa8a25fd4f37.tar.gz
Restoring authorship annotation for <vavbrs@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'library/cpp/containers/intrusive_rb_tree/rb_tree_ut.cpp')
-rw-r--r--library/cpp/containers/intrusive_rb_tree/rb_tree_ut.cpp110
1 files changed, 55 insertions, 55 deletions
diff --git a/library/cpp/containers/intrusive_rb_tree/rb_tree_ut.cpp b/library/cpp/containers/intrusive_rb_tree/rb_tree_ut.cpp
index c34ed1fd9b..2fab91405a 100644
--- a/library/cpp/containers/intrusive_rb_tree/rb_tree_ut.cpp
+++ b/library/cpp/containers/intrusive_rb_tree/rb_tree_ut.cpp
@@ -4,7 +4,7 @@
#include <util/random/fast.h>
#include <util/random/easy.h>
-#include <util/random/shuffle.h>
+#include <util/random/shuffle.h>
class TRedBlackTreeTest: public TTestBase {
struct TCmp {
@@ -42,10 +42,10 @@ class TRedBlackTreeTest: public TTestBase {
UNIT_TEST(TestErase)
UNIT_TEST(TestFind)
UNIT_TEST(TestStress)
- UNIT_TEST(TestGettingIndexWithDifferentValues)
+ UNIT_TEST(TestGettingIndexWithDifferentValues)
UNIT_TEST(TestCheckChildrenAfterErase)
UNIT_TEST(TestGettingIndexWithDifferentValuesAfterErase)
- UNIT_TEST(TestGettingIndexWithEqualValues)
+ UNIT_TEST(TestGettingIndexWithEqualValues)
UNIT_TEST(TestLessCountOnEmptyTree)
UNIT_TEST_SUITE_END();
@@ -77,33 +77,33 @@ private:
}
}
- inline void TestGettingIndexWithDifferentValues() {
+ inline void TestGettingIndexWithDifferentValues() {
TVector<TSimpleSharedPtr<TNode>> nodes;
- size_t N = 1000;
-
- for (size_t i = 0; i < N; ++i) {
- nodes.push_back(new TNode(int(i)));
- }
-
- TTree tree;
- Shuffle(nodes.begin(), nodes.end());
-
- for (size_t i = 0; i < N; ++i) {
- tree.Insert(nodes[i].Get());
- }
-
- for (size_t i = 0; i < N; ++i) {
- UNIT_ASSERT_EQUAL(tree.LessCount(i), i);
- UNIT_ASSERT_EQUAL(tree.NotGreaterCount(i), i + 1);
- UNIT_ASSERT_EQUAL(tree.GreaterCount(i), N - i - 1);
- UNIT_ASSERT_EQUAL(tree.NotLessCount(i), N - i);
-
- auto nodePtr = tree.Find(i);
- UNIT_ASSERT_EQUAL(tree.GetIndex(nodePtr), i);
- UNIT_ASSERT_EQUAL(tree.GetIndex(nodes[i].Get()), static_cast<size_t>(nodes[i]->N));
- }
- }
-
+ size_t N = 1000;
+
+ for (size_t i = 0; i < N; ++i) {
+ nodes.push_back(new TNode(int(i)));
+ }
+
+ TTree tree;
+ Shuffle(nodes.begin(), nodes.end());
+
+ for (size_t i = 0; i < N; ++i) {
+ tree.Insert(nodes[i].Get());
+ }
+
+ for (size_t i = 0; i < N; ++i) {
+ UNIT_ASSERT_EQUAL(tree.LessCount(i), i);
+ UNIT_ASSERT_EQUAL(tree.NotGreaterCount(i), i + 1);
+ UNIT_ASSERT_EQUAL(tree.GreaterCount(i), N - i - 1);
+ UNIT_ASSERT_EQUAL(tree.NotLessCount(i), N - i);
+
+ auto nodePtr = tree.Find(i);
+ UNIT_ASSERT_EQUAL(tree.GetIndex(nodePtr), i);
+ UNIT_ASSERT_EQUAL(tree.GetIndex(nodes[i].Get()), static_cast<size_t>(nodes[i]->N));
+ }
+ }
+
inline void TestCheckChildrenAfterErase() {
TVector<TSimpleSharedPtr<TNode>> nodes;
size_t N = 1000;
@@ -175,33 +175,33 @@ private:
}
}
- inline void TestGettingIndexWithEqualValues() {
+ inline void TestGettingIndexWithEqualValues() {
TVector<TSimpleSharedPtr<TNode>> nodes;
- size_t N = 1000;
-
- for (size_t i = 0; i < N; ++i) {
- nodes.push_back(new TNode(0));
- }
-
- TTree tree;
-
- for (size_t i = 0; i < N; ++i) {
- tree.Insert(nodes[i].Get());
- }
-
- for (size_t i = 0; i < N; ++i) {
- UNIT_ASSERT_EQUAL(tree.LessCount(nodes[i]->N), 0);
- UNIT_ASSERT_EQUAL(tree.NotGreaterCount(nodes[i]->N), N);
- UNIT_ASSERT_EQUAL(tree.GreaterCount(nodes[i]->N), 0);
- UNIT_ASSERT_EQUAL(tree.NotLessCount(nodes[i]->N), N);
-
- UNIT_ASSERT_EQUAL(tree.LessCount(*nodes[i].Get()), 0);
- UNIT_ASSERT_EQUAL(tree.NotGreaterCount(*nodes[i].Get()), N);
- UNIT_ASSERT_EQUAL(tree.GreaterCount(*nodes[i].Get()), 0);
- UNIT_ASSERT_EQUAL(tree.NotLessCount(*nodes[i].Get()), N);
- }
- }
-
+ size_t N = 1000;
+
+ for (size_t i = 0; i < N; ++i) {
+ nodes.push_back(new TNode(0));
+ }
+
+ TTree tree;
+
+ for (size_t i = 0; i < N; ++i) {
+ tree.Insert(nodes[i].Get());
+ }
+
+ for (size_t i = 0; i < N; ++i) {
+ UNIT_ASSERT_EQUAL(tree.LessCount(nodes[i]->N), 0);
+ UNIT_ASSERT_EQUAL(tree.NotGreaterCount(nodes[i]->N), N);
+ UNIT_ASSERT_EQUAL(tree.GreaterCount(nodes[i]->N), 0);
+ UNIT_ASSERT_EQUAL(tree.NotLessCount(nodes[i]->N), N);
+
+ UNIT_ASSERT_EQUAL(tree.LessCount(*nodes[i].Get()), 0);
+ UNIT_ASSERT_EQUAL(tree.NotGreaterCount(*nodes[i].Get()), N);
+ UNIT_ASSERT_EQUAL(tree.GreaterCount(*nodes[i].Get()), 0);
+ UNIT_ASSERT_EQUAL(tree.NotLessCount(*nodes[i].Get()), N);
+ }
+ }
+
inline void TestFind() {
TTree tree;