diff options
author | ermolovd <ermolovd@yandex-team.ru> | 2022-02-10 16:47:53 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:47:53 +0300 |
commit | b91bcef7c99a119b0846479ef71bfab4beec72ca (patch) | |
tree | be118d54d12a61bc4812ceb0a266a170a2fa3bc9 /util/generic | |
parent | f421873774cf0b71743afbe5f6677861e66601ea (diff) | |
download | ydb-b91bcef7c99a119b0846479ef71bfab4beec72ca.tar.gz |
Restoring authorship annotation for <ermolovd@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'util/generic')
-rw-r--r-- | util/generic/deque.h | 2 | ||||
-rw-r--r-- | util/generic/deque_ut.cpp | 8 | ||||
-rw-r--r-- | util/generic/hash.h | 50 | ||||
-rw-r--r-- | util/generic/hash_set.h | 12 | ||||
-rw-r--r-- | util/generic/hash_ut.cpp | 140 | ||||
-rw-r--r-- | util/generic/list.h | 2 | ||||
-rw-r--r-- | util/generic/list_ut.cpp | 18 | ||||
-rw-r--r-- | util/generic/map.h | 2 | ||||
-rw-r--r-- | util/generic/map_ut.cpp | 50 | ||||
-rw-r--r-- | util/generic/ptr.h | 44 | ||||
-rw-r--r-- | util/generic/ptr_ut.cpp | 104 | ||||
-rw-r--r-- | util/generic/set.h | 2 |
12 files changed, 217 insertions, 217 deletions
diff --git a/util/generic/deque.h b/util/generic/deque.h index 2dabaf3177..f4f2e8baa8 100644 --- a/util/generic/deque.h +++ b/util/generic/deque.h @@ -6,7 +6,7 @@ #include <deque> #include <memory> -#include <initializer_list> +#include <initializer_list> template <class T, class A> class TDeque: public std::deque<T, TReboundAllocator<A, T>> { diff --git a/util/generic/deque_ut.cpp b/util/generic/deque_ut.cpp index 93bf50fa92..f1b71c3ca8 100644 --- a/util/generic/deque_ut.cpp +++ b/util/generic/deque_ut.cpp @@ -59,10 +59,10 @@ void TDequeTest::TestConstructorsAndAssignments() { UNIT_ASSERT_VALUES_EQUAL(0, c2.size()); UNIT_ASSERT_VALUES_EQUAL(4, c3.size()); UNIT_ASSERT_VALUES_EQUAL(400, c3.at(3)); - - int array[] = {2, 3, 4}; - container c4 = {2, 3, 4}; - UNIT_ASSERT_VALUES_EQUAL(c4, container(std::begin(array), std::end(array))); + + int array[] = {2, 3, 4}; + container c4 = {2, 3, 4}; + UNIT_ASSERT_VALUES_EQUAL(c4, container(std::begin(array), std::end(array))); } void TDequeTest::TestDeque1() { diff --git a/util/generic/hash.h b/util/generic/hash.h index e46db21fa9..1ae5b8c476 100644 --- a/util/generic/hash.h +++ b/util/generic/hash.h @@ -12,9 +12,9 @@ #include "utility.h" #include <algorithm> -#include <initializer_list> -#include <memory> -#include <tuple> +#include <initializer_list> +#include <memory> +#include <tuple> #include <utility> #include <cstdlib> @@ -1834,13 +1834,13 @@ public: } THashMultiMap(std::initializer_list<std::pair<Key, T>> list) - : rep(list.size(), hasher(), key_equal()) - { - for (const auto& v : list) { - rep.emplace_equal_noresize(v); - } - } - + : rep(list.size(), hasher(), key_equal()) + { + for (const auto& v : list) { + rep.emplace_equal_noresize(v); + } + } + // THashMultiMap has implicit copy/move constructors and copy-/move-assignment operators // because its implementation is backed by THashTable. // See hash_ut.cpp @@ -1996,25 +1996,25 @@ public: template <class Key, class T, class HF, class EqKey, class Alloc> inline bool operator==(const THashMultiMap<Key, T, HF, EqKey, Alloc>& hm1, const THashMultiMap<Key, T, HF, EqKey, Alloc>& hm2) { - // NOTE: copy-pasted from - // contrib/libs/cxxsupp/libcxx/include/unordered_map + // NOTE: copy-pasted from + // contrib/libs/cxxsupp/libcxx/include/unordered_map // and adapted to THashMultiMap - if (hm1.size() != hm2.size()) { - return false; - } + if (hm1.size() != hm2.size()) { + return false; + } using const_iterator = typename THashMultiMap<Key, T, HF, EqKey, Alloc>::const_iterator; - using TEqualRange = std::pair<const_iterator, const_iterator>; - for (const_iterator it = hm1.begin(), end = hm1.end(); it != end;) { - TEqualRange eq1 = hm1.equal_range(it->first); - TEqualRange eq2 = hm2.equal_range(it->first); - if (std::distance(eq1.first, eq1.second) != std::distance(eq2.first, eq2.second) || + using TEqualRange = std::pair<const_iterator, const_iterator>; + for (const_iterator it = hm1.begin(), end = hm1.end(); it != end;) { + TEqualRange eq1 = hm1.equal_range(it->first); + TEqualRange eq2 = hm2.equal_range(it->first); + if (std::distance(eq1.first, eq1.second) != std::distance(eq2.first, eq2.second) || !std::is_permutation(eq1.first, eq1.second, eq2.first)) { - return false; - } - it = eq1.second; - } - return true; + return false; + } + it = eq1.second; + } + return true; } template <class Key, class T, class HF, class EqKey, class Alloc> diff --git a/util/generic/hash_set.h b/util/generic/hash_set.h index e8088cf23b..66c9bd5167 100644 --- a/util/generic/hash_set.h +++ b/util/generic/hash_set.h @@ -64,7 +64,7 @@ public: } THashSet(std::initializer_list<value_type> list) - : rep(list.size(), hasher(), key_equal()) + : rep(list.size(), hasher(), key_equal()) { rep.insert_unique(list.begin(), list.end()); } @@ -355,11 +355,11 @@ public: } THashMultiSet(std::initializer_list<value_type> list) - : rep(list.size(), hasher(), key_equal()) - { - rep.insert_equal(list.begin(), list.end()); - } - + : rep(list.size(), hasher(), key_equal()) + { + rep.insert_equal(list.begin(), list.end()); + } + // THashMultiSet has implicit copy/move constructors and copy-/move-assignment operators // because its implementation is backed by THashTable. // See hash_ut.cpp diff --git a/util/generic/hash_ut.cpp b/util/generic/hash_ut.cpp index 0551d58770..98f6fdaee5 100644 --- a/util/generic/hash_ut.cpp +++ b/util/generic/hash_ut.cpp @@ -16,7 +16,7 @@ class THashTest: public TTestBase { UNIT_TEST(TestHMapConstructorsAndAssignments); UNIT_TEST(TestHMap1); UNIT_TEST(TestHMapEqualityOperator); - UNIT_TEST(TestHMMapEqualityOperator); + UNIT_TEST(TestHMMapEqualityOperator); UNIT_TEST(TestHMMapConstructorsAndAssignments); UNIT_TEST(TestHMMap1); UNIT_TEST(TestHMMapHas); @@ -53,10 +53,10 @@ class THashTest: public TTestBase { UNIT_TEST(TestAssignmentClear); UNIT_TEST(TestReleaseNodes); UNIT_TEST(TestAt); - UNIT_TEST(TestHMapInitializerList); - UNIT_TEST(TestHMMapInitializerList); - UNIT_TEST(TestHSetInitializerList); - UNIT_TEST(TestHMSetInitializerList); + UNIT_TEST(TestHMapInitializerList); + UNIT_TEST(TestHMMapInitializerList); + UNIT_TEST(TestHSetInitializerList); + UNIT_TEST(TestHMSetInitializerList); UNIT_TEST(TestHSetInsertInitializerList); UNIT_TEST(TestTupleHash); UNIT_TEST_SUITE_END(); @@ -67,7 +67,7 @@ protected: void TestHMapConstructorsAndAssignments(); void TestHMap1(); void TestHMapEqualityOperator(); - void TestHMMapEqualityOperator(); + void TestHMMapEqualityOperator(); void TestHMMapConstructorsAndAssignments(); void TestHMMap1(); void TestHMMapHas(); @@ -104,10 +104,10 @@ protected: void TestAssignmentClear(); void TestReleaseNodes(); void TestAt(); - void TestHMapInitializerList(); - void TestHMMapInitializerList(); - void TestHSetInitializerList(); - void TestHMSetInitializerList(); + void TestHMapInitializerList(); + void TestHMMapInitializerList(); + void TestHSetInitializerList(); + void TestHMSetInitializerList(); void TestHSetInsertInitializerList(); void TestTupleHash(); }; @@ -225,41 +225,41 @@ void THashTest::TestHMapEqualityOperator() { UNIT_ASSERT(c3 != base); } -void THashTest::TestHMMapEqualityOperator() { +void THashTest::TestHMMapEqualityOperator() { using container = THashMultiMap<TString, int>; - using value = container::value_type; - - container base; - base.insert(value("one", 1)); - base.insert(value("one", -1)); - base.insert(value("two", 2)); - - container c1(base); - UNIT_ASSERT(c1 == base); - - container c2; - c2.insert(value("two", 2)); - c2.insert(value("one", -1)); - c2.insert(value("one", 1)); - UNIT_ASSERT(c2 == base); - - c2.insert(value("three", 3)); - UNIT_ASSERT(c2 != base); - - container c3; - c3.insert(value("one", 0)); - c3.insert(value("one", -1)); - c3.insert(value("two", 2)); - UNIT_ASSERT(c3 != base); - - container c4; - c4.insert(value("one", 1)); - c4.insert(value("one", -1)); - c4.insert(value("one", 0)); - c4.insert(value("two", 2)); - UNIT_ASSERT(c3 != base); -} - + using value = container::value_type; + + container base; + base.insert(value("one", 1)); + base.insert(value("one", -1)); + base.insert(value("two", 2)); + + container c1(base); + UNIT_ASSERT(c1 == base); + + container c2; + c2.insert(value("two", 2)); + c2.insert(value("one", -1)); + c2.insert(value("one", 1)); + UNIT_ASSERT(c2 == base); + + c2.insert(value("three", 3)); + UNIT_ASSERT(c2 != base); + + container c3; + c3.insert(value("one", 0)); + c3.insert(value("one", -1)); + c3.insert(value("two", 2)); + UNIT_ASSERT(c3 != base); + + container c4; + c4.insert(value("one", 1)); + c4.insert(value("one", -1)); + c4.insert(value("one", 0)); + c4.insert(value("two", 2)); + UNIT_ASSERT(c3 != base); +} + void THashTest::TestHMMapConstructorsAndAssignments() { using container = THashMultiMap<TString, int>; @@ -1147,46 +1147,46 @@ void THashTest::TestAt() { #undef TEST_AT_THROWN_EXCEPTION } - -void THashTest::TestHMapInitializerList() { + +void THashTest::TestHMapInitializerList() { THashMap<TString, TString> h1 = {{"foo", "bar"}, {"bar", "baz"}, {"baz", "qux"}}; THashMap<TString, TString> h2; h2.insert(std::pair<TString, TString>("foo", "bar")); h2.insert(std::pair<TString, TString>("bar", "baz")); h2.insert(std::pair<TString, TString>("baz", "qux")); - UNIT_ASSERT_EQUAL(h1, h2); -} - -void THashTest::TestHMMapInitializerList() { + UNIT_ASSERT_EQUAL(h1, h2); +} + +void THashTest::TestHMMapInitializerList() { THashMultiMap<TString, TString> h1 = { - {"foo", "bar"}, - {"foo", "baz"}, - {"baz", "qux"}}; + {"foo", "bar"}, + {"foo", "baz"}, + {"baz", "qux"}}; THashMultiMap<TString, TString> h2; h2.insert(std::pair<TString, TString>("foo", "bar")); h2.insert(std::pair<TString, TString>("foo", "baz")); h2.insert(std::pair<TString, TString>("baz", "qux")); - UNIT_ASSERT_EQUAL(h1, h2); -} - -void THashTest::TestHSetInitializerList() { + UNIT_ASSERT_EQUAL(h1, h2); +} + +void THashTest::TestHSetInitializerList() { THashSet<TString> h1 = {"foo", "bar", "baz"}; THashSet<TString> h2; - h2.insert("foo"); - h2.insert("bar"); - h2.insert("baz"); - UNIT_ASSERT_EQUAL(h1, h2); -} - -void THashTest::TestHMSetInitializerList() { + h2.insert("foo"); + h2.insert("bar"); + h2.insert("baz"); + UNIT_ASSERT_EQUAL(h1, h2); +} + +void THashTest::TestHMSetInitializerList() { THashMultiSet<TString> h1 = {"foo", "foo", "bar", "baz"}; THashMultiSet<TString> h2; - h2.insert("foo"); - h2.insert("foo"); - h2.insert("bar"); - h2.insert("baz"); - UNIT_ASSERT_EQUAL(h1, h2); -} + h2.insert("foo"); + h2.insert("foo"); + h2.insert("bar"); + h2.insert("baz"); + UNIT_ASSERT_EQUAL(h1, h2); +} namespace { struct TFoo { diff --git a/util/generic/list.h b/util/generic/list.h index 7b0b8ffc72..ddeb94be92 100644 --- a/util/generic/list.h +++ b/util/generic/list.h @@ -4,7 +4,7 @@ #include <util/memory/alloc.h> -#include <initializer_list> +#include <initializer_list> #include <list> #include <memory> #include <utility> diff --git a/util/generic/list_ut.cpp b/util/generic/list_ut.cpp index 9e60ecf01b..7101ee1843 100644 --- a/util/generic/list_ut.cpp +++ b/util/generic/list_ut.cpp @@ -1,14 +1,14 @@ -#include "list.h" - +#include "list.h" + #include <library/cpp/testing/unittest/registar.h> - + Y_UNIT_TEST_SUITE(TYListSuite) { Y_UNIT_TEST(TestInitializerList) { TList<int> l = {3, 42, 6}; TList<int> expected; - expected.push_back(3); - expected.push_back(42); - expected.push_back(6); - UNIT_ASSERT_VALUES_EQUAL(l, expected); - } -} + expected.push_back(3); + expected.push_back(42); + expected.push_back(6); + UNIT_ASSERT_VALUES_EQUAL(l, expected); + } +} diff --git a/util/generic/map.h b/util/generic/map.h index b5001b56c0..81698d753a 100644 --- a/util/generic/map.h +++ b/util/generic/map.h @@ -7,7 +7,7 @@ #include <util/memory/alloc.h> #include <utility> -#include <initializer_list> +#include <initializer_list> #include <map> #include <memory> diff --git a/util/generic/map_ut.cpp b/util/generic/map_ut.cpp index 79e832b024..8e01c8f365 100644 --- a/util/generic/map_ut.cpp +++ b/util/generic/map_ut.cpp @@ -445,37 +445,37 @@ Y_UNIT_TEST_SUITE(TYMapTest) { UNIT_ASSERT_VALUES_EQUAL(values[2], 101); } } - + Y_UNIT_TEST(TestMapInitializerList) { TMap<TString, int> m = { - {"one", 1}, - {"two", 2}, - {"three", 3}, - {"four", 4}, - }; - - UNIT_ASSERT_VALUES_EQUAL(m.size(), 4); - UNIT_ASSERT_VALUES_EQUAL(m["one"], 1); - UNIT_ASSERT_VALUES_EQUAL(m["two"], 2); - UNIT_ASSERT_VALUES_EQUAL(m["three"], 3); - UNIT_ASSERT_VALUES_EQUAL(m["four"], 4); - } - + {"one", 1}, + {"two", 2}, + {"three", 3}, + {"four", 4}, + }; + + UNIT_ASSERT_VALUES_EQUAL(m.size(), 4); + UNIT_ASSERT_VALUES_EQUAL(m["one"], 1); + UNIT_ASSERT_VALUES_EQUAL(m["two"], 2); + UNIT_ASSERT_VALUES_EQUAL(m["three"], 3); + UNIT_ASSERT_VALUES_EQUAL(m["four"], 4); + } + Y_UNIT_TEST(TestMMapInitializerList) { TMultiMap<TString, int> mm = { - {"one", 1}, - {"two", 2}, - {"two", -2}, - {"three", 3}, - }; + {"one", 1}, + {"two", 2}, + {"two", -2}, + {"three", 3}, + }; UNIT_ASSERT(mm.contains("two")); TMultiMap<TString, int> expected; - expected.emplace("one", 1); - expected.emplace("two", 2); - expected.emplace("two", -2); - expected.emplace("three", 3); - UNIT_ASSERT_VALUES_EQUAL(mm, expected); - } + expected.emplace("one", 1); + expected.emplace("two", 2); + expected.emplace("two", -2); + expected.emplace("three", 3); + UNIT_ASSERT_VALUES_EQUAL(mm, expected); + } Y_UNIT_TEST(TestMovePoolAlloc) { using TMapInPool = TMap<int, int, TLess<int>, TPoolAllocator>; diff --git a/util/generic/ptr.h b/util/generic/ptr.h index 19db0e3ec5..fa15f3a378 100644 --- a/util/generic/ptr.h +++ b/util/generic/ptr.h @@ -4,7 +4,7 @@ #include "utility.h" #include "intrlist.h" #include "refcount.h" -#include "typetraits.h" +#include "typetraits.h" #include "singleton.h" #include <utility> @@ -508,22 +508,22 @@ public: Ref(); } - // NOTE: + // NOTE: // without std::enable_if_t compiler sometimes tries to use this constructor inappropriately - // e.g. - // struct A {}; - // struct B {}; - // void Func(TIntrusivePtr<A>); - // void Func(TIntrusivePtr<B>); - // ... - // Func(TIntrusivePtr<A>(new A)); // <--- compiler can't decide which version of Func to use + // e.g. + // struct A {}; + // struct B {}; + // void Func(TIntrusivePtr<A>); + // void Func(TIntrusivePtr<B>); + // ... + // Func(TIntrusivePtr<A>(new A)); // <--- compiler can't decide which version of Func to use template <class U, class = TGuardConversion<T, U>> inline TIntrusivePtr(const TIntrusivePtr<U>& p) noexcept - : T_(p.Get()) - { - Ref(); - } - + : T_(p.Get()) + { + Ref(); + } + template <class U, class = TGuardConversion<T, U>> inline TIntrusivePtr(TIntrusivePtr<U>&& p) noexcept : T_(p.T_) @@ -645,11 +645,11 @@ public: template <class U, class = TGuardConversion<T, U>> inline TIntrusiveConstPtr(const TIntrusiveConstPtr<U>& p) noexcept - : T_(p.T_) - { - Ref(); - } - + : T_(p.T_) + { + Ref(); + } + template <class U, class = TGuardConversion<T, U>> inline TIntrusiveConstPtr(TIntrusiveConstPtr<U>&& p) noexcept : T_(p.T_) @@ -711,9 +711,9 @@ private: private: T* T_; - - template <class U, class O> - friend class TIntrusiveConstPtr; + + template <class U, class O> + friend class TIntrusiveConstPtr; }; template <class T, class Ops> diff --git a/util/generic/ptr_ut.cpp b/util/generic/ptr_ut.cpp index c2dcff23f6..a53f819c1f 100644 --- a/util/generic/ptr_ut.cpp +++ b/util/generic/ptr_ut.cpp @@ -23,8 +23,8 @@ class TPointerTest: public TTestBase { UNIT_TEST(TestAutoToHolder); UNIT_TEST(TestCopyPtr); UNIT_TEST(TestIntrPtr); - UNIT_TEST(TestIntrusiveConvertion); - UNIT_TEST(TestIntrusiveConstConvertion); + UNIT_TEST(TestIntrusiveConvertion); + UNIT_TEST(TestIntrusiveConstConvertion); UNIT_TEST(TestIntrusiveConstConstruction); UNIT_TEST(TestMakeIntrusive); UNIT_TEST(TestCopyOnWritePtr1); @@ -75,8 +75,8 @@ private: void TestAutoToHolder(); void TestCopyPtr(); void TestIntrPtr(); - void TestIntrusiveConvertion(); - void TestIntrusiveConstConvertion(); + void TestIntrusiveConvertion(); + void TestIntrusiveConstConvertion(); void TestIntrusiveConstConstruction(); void TestMakeIntrusive(); void TestCopyOnWritePtr1(); @@ -364,59 +364,59 @@ void TPointerTest::TestIntrPtr() { UNIT_ASSERT_VALUES_EQUAL(TOp::Cnt, 0); } -namespace NTestIntrusiveConvertion { +namespace NTestIntrusiveConvertion { struct TA: public TSimpleRefCount<TA> { - }; + }; struct TAA: public TA { - }; + }; struct TB: public TSimpleRefCount<TB> { - }; - - void Func(TIntrusivePtr<TA>) { - } - - void Func(TIntrusivePtr<TB>) { - } - - void Func(TIntrusiveConstPtr<TA>) { - } - - void Func(TIntrusiveConstPtr<TB>) { - } -} - + }; + + void Func(TIntrusivePtr<TA>) { + } + + void Func(TIntrusivePtr<TB>) { + } + + void Func(TIntrusiveConstPtr<TA>) { + } + + void Func(TIntrusiveConstPtr<TB>) { + } +} + void TPointerTest::TestIntrusiveConvertion() { - using namespace NTestIntrusiveConvertion; - - TIntrusivePtr<TAA> aa = new TAA; - - UNIT_ASSERT_VALUES_EQUAL(aa->RefCount(), 1); - TIntrusivePtr<TA> a = aa; - UNIT_ASSERT_VALUES_EQUAL(aa->RefCount(), 2); - UNIT_ASSERT_VALUES_EQUAL(a->RefCount(), 2); - aa.Reset(); - UNIT_ASSERT_VALUES_EQUAL(a->RefCount(), 1); - - // test that Func(TIntrusivePtr<TB>) doesn't participate in overload resolution - Func(aa); -} - + using namespace NTestIntrusiveConvertion; + + TIntrusivePtr<TAA> aa = new TAA; + + UNIT_ASSERT_VALUES_EQUAL(aa->RefCount(), 1); + TIntrusivePtr<TA> a = aa; + UNIT_ASSERT_VALUES_EQUAL(aa->RefCount(), 2); + UNIT_ASSERT_VALUES_EQUAL(a->RefCount(), 2); + aa.Reset(); + UNIT_ASSERT_VALUES_EQUAL(a->RefCount(), 1); + + // test that Func(TIntrusivePtr<TB>) doesn't participate in overload resolution + Func(aa); +} + void TPointerTest::TestIntrusiveConstConvertion() { - using namespace NTestIntrusiveConvertion; - - TIntrusiveConstPtr<TAA> aa = new TAA; - - UNIT_ASSERT_VALUES_EQUAL(aa->RefCount(), 1); - TIntrusiveConstPtr<TA> a = aa; - UNIT_ASSERT_VALUES_EQUAL(aa->RefCount(), 2); - UNIT_ASSERT_VALUES_EQUAL(a->RefCount(), 2); - aa.Reset(); - UNIT_ASSERT_VALUES_EQUAL(a->RefCount(), 1); - - // test that Func(TIntrusiveConstPtr<TB>) doesn't participate in overload resolution - Func(aa); -} - + using namespace NTestIntrusiveConvertion; + + TIntrusiveConstPtr<TAA> aa = new TAA; + + UNIT_ASSERT_VALUES_EQUAL(aa->RefCount(), 1); + TIntrusiveConstPtr<TA> a = aa; + UNIT_ASSERT_VALUES_EQUAL(aa->RefCount(), 2); + UNIT_ASSERT_VALUES_EQUAL(a->RefCount(), 2); + aa.Reset(); + UNIT_ASSERT_VALUES_EQUAL(a->RefCount(), 1); + + // test that Func(TIntrusiveConstPtr<TB>) doesn't participate in overload resolution + Func(aa); +} + void TPointerTest::TestMakeIntrusive() { { UNIT_ASSERT_VALUES_EQUAL(0, TOp::Cnt); diff --git a/util/generic/set.h b/util/generic/set.h index 4c437ca26f..575d16d064 100644 --- a/util/generic/set.h +++ b/util/generic/set.h @@ -5,7 +5,7 @@ #include <util/str_stl.h> #include <util/memory/alloc.h> -#include <initializer_list> +#include <initializer_list> #include <memory> #include <set> |