diff options
author | pavelgur <pavelgur@yandex-team.ru> | 2022-02-10 16:50:19 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:50:19 +0300 |
commit | db222959b3748242024c781f563f31a342492476 (patch) | |
tree | 5d5cb817648f650d76cf1076100726fd9b8448e8 /util | |
parent | 173c6a0fa7f439b2c207c2f258e52ccb4ac181cf (diff) | |
download | ydb-db222959b3748242024c781f563f31a342492476.tar.gz |
Restoring authorship annotation for <pavelgur@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'util')
-rw-r--r-- | util/charset/wide.h | 10 | ||||
-rw-r--r-- | util/digest/multi.cpp | 2 | ||||
-rw-r--r-- | util/digest/multi.h | 18 | ||||
-rw-r--r-- | util/digest/multi_ut.cpp | 38 | ||||
-rw-r--r-- | util/generic/algorithm.h | 8 | ||||
-rw-r--r-- | util/generic/array_ref.h | 6 | ||||
-rw-r--r-- | util/generic/array_ref_ut.cpp | 18 | ||||
-rw-r--r-- | util/generic/hash.h | 24 | ||||
-rw-r--r-- | util/generic/hash_set.h | 2 | ||||
-rw-r--r-- | util/generic/hash_ut.cpp | 22 | ||||
-rw-r--r-- | util/generic/noncopyable.h | 4 | ||||
-rw-r--r-- | util/generic/queue_ut.cpp | 42 | ||||
-rw-r--r-- | util/generic/utility.h | 24 | ||||
-rw-r--r-- | util/generic/utility_ut.cpp | 4 |
14 files changed, 111 insertions, 111 deletions
diff --git a/util/charset/wide.h b/util/charset/wide.h index 950c6c44e6..04e6928aab 100644 --- a/util/charset/wide.h +++ b/util/charset/wide.h @@ -406,12 +406,12 @@ inline void WideToUTF8(const TCharType* text, size_t len, char* dest, size_t& wr written = p - reinterpret_cast<unsigned char*>(dest); } -constexpr size_t WideToUTF8BufferSize(const size_t inputStringSize) noexcept { - return inputStringSize * 4; // * 4 because the conversion functions can convert unicode character into maximum 4 bytes of UTF8 -} - +constexpr size_t WideToUTF8BufferSize(const size_t inputStringSize) noexcept { + return inputStringSize * 4; // * 4 because the conversion functions can convert unicode character into maximum 4 bytes of UTF8 +} + inline TStringBuf WideToUTF8(const TWtringBuf src, TString& dst) { - dst.ReserveAndResize(WideToUTF8BufferSize(src.size())); + dst.ReserveAndResize(WideToUTF8BufferSize(src.size())); size_t written = 0; WideToUTF8(src.data(), src.size(), dst.begin(), written); Y_ASSERT(dst.size() >= written); diff --git a/util/digest/multi.cpp b/util/digest/multi.cpp index 74db0818b7..e4a59f0e67 100644 --- a/util/digest/multi.cpp +++ b/util/digest/multi.cpp @@ -1 +1 @@ -#include "multi.h" +#include "multi.h" diff --git a/util/digest/multi.h b/util/digest/multi.h index 9b2d5f2f88..8e4597c9dc 100644 --- a/util/digest/multi.h +++ b/util/digest/multi.h @@ -1,14 +1,14 @@ -#pragma once - -#include <util/str_stl.h> - -#include "numeric.h" - +#pragma once + +#include <util/str_stl.h> + +#include "numeric.h" + template <typename TOne> constexpr size_t MultiHash(const TOne& one) noexcept { - return THash<TOne>()(one); -} + return THash<TOne>()(one); +} template <typename THead, typename... TTail> constexpr size_t MultiHash(const THead& head, const TTail&... tail) noexcept { return CombineHashes(MultiHash(tail...), THash<THead>()(head)); -} +} diff --git a/util/digest/multi_ut.cpp b/util/digest/multi_ut.cpp index 9d508c4ce8..dff64ff0cc 100644 --- a/util/digest/multi_ut.cpp +++ b/util/digest/multi_ut.cpp @@ -1,25 +1,25 @@ -#include "multi.h" - +#include "multi.h" + #include <library/cpp/testing/unittest/registar.h> - + #include <util/stream/output.h> - -class TMultiHashTest: public TTestBase { - UNIT_TEST_SUITE(TMultiHashTest); - UNIT_TEST(TestStrInt) - UNIT_TEST(TestIntStr) + +class TMultiHashTest: public TTestBase { + UNIT_TEST_SUITE(TMultiHashTest); + UNIT_TEST(TestStrInt) + UNIT_TEST(TestIntStr) UNIT_TEST(TestSimpleCollision) UNIT_TEST(TestTypes) - UNIT_TEST_SUITE_END(); - -private: - inline void TestStrInt() { + UNIT_TEST_SUITE_END(); + +private: + inline void TestStrInt() { UNIT_ASSERT_EQUAL(MultiHash(TString("1234567"), static_cast<int>(123)), static_cast<size_t>(ULL(17038203285960021630))); - } - - inline void TestIntStr() { + } + + inline void TestIntStr() { UNIT_ASSERT_EQUAL(MultiHash(static_cast<int>(123), TString("1234567")), static_cast<size_t>(ULL(9973288649881090712))); - } + } inline void TestSimpleCollision() { UNIT_ASSERT_UNEQUAL(MultiHash(1, 1, 0), MultiHash(2, 2, 0)); @@ -33,6 +33,6 @@ private: UNIT_ASSERT_EQUAL(MultiHash("aaa", (i64)-123), MultiHash("aaa", -123)); UNIT_ASSERT_EQUAL(MultiHash("aaa", (i32)-123), MultiHash("aaa", -123)); } -}; - -UNIT_TEST_SUITE_REGISTRATION(TMultiHashTest); +}; + +UNIT_TEST_SUITE_REGISTRATION(TMultiHashTest); diff --git a/util/generic/algorithm.h b/util/generic/algorithm.h index 2d184ee7e0..badfb88993 100644 --- a/util/generic/algorithm.h +++ b/util/generic/algorithm.h @@ -439,10 +439,10 @@ static inline void Fill(I f, I l, const T& v) { } template <typename I, typename S, typename T> -static inline I FillN(I f, S n, const T& v) { - return std::fill_n(f, n, v); -} - +static inline I FillN(I f, S n, const T& v) { + return std::fill_n(f, n, v); +} + template <class T> static inline void Reverse(T f, T l) { std::reverse(f, l); diff --git a/util/generic/array_ref.h b/util/generic/array_ref.h index ddaf6bdceb..1ac60ac7d3 100644 --- a/util/generic/array_ref.h +++ b/util/generic/array_ref.h @@ -2,10 +2,10 @@ #include <util/generic/yexception.h> -#include <algorithm> +#include <algorithm> #include <initializer_list> #include <iterator> - + /** * `TArrayRef` works pretty much like `std::span` with dynamic extent, presenting * an array-like interface into a contiguous sequence of objects. @@ -77,7 +77,7 @@ public: bool operator==(const TArrayRef<TT>& other) const noexcept { return (S_ == other.size()) && std::equal(begin(), end(), other.begin()); } - + constexpr inline T* data() const noexcept { return T_; } diff --git a/util/generic/array_ref_ut.cpp b/util/generic/array_ref_ut.cpp index 89add6e8d1..4c8eaf7135 100644 --- a/util/generic/array_ref_ut.cpp +++ b/util/generic/array_ref_ut.cpp @@ -139,27 +139,27 @@ Y_UNIT_TEST_SUITE(TestArrayRef) { UNIT_ASSERT_VALUES_EQUAL(autoSizeRef[0], '4'); UNIT_ASSERT_VALUES_EQUAL(autoSizeRef[3], '\0'); } - + Y_UNIT_TEST(TestEqualityOperator) { - static constexpr size_t size = 5; + static constexpr size_t size = 5; int a[size]{1, 2, 3, 4, 5}; int b[size]{5, 4, 3, 2, 1}; int c[size - 1]{5, 4, 3, 2}; float d[size]{1.f, 2.f, 3.f, 4.f, 5.f}; - + TArrayRef<int> aRef(a); TConstArrayRef<int> aConstRef(a, size); - + TArrayRef<int> bRef(b); - + TArrayRef<int> cRef(c, size - 1); - + TArrayRef<float> dRef(d, size); TConstArrayRef<float> dConstRef(d, size); - + UNIT_ASSERT_EQUAL(aRef, aConstRef); UNIT_ASSERT_EQUAL(dRef, dConstRef); - + UNIT_ASSERT_UNEQUAL(aRef, cRef); UNIT_ASSERT_UNEQUAL(aRef, bRef); @@ -167,7 +167,7 @@ Y_UNIT_TEST_SUITE(TestArrayRef) { //Testing if operator== compares values, not pointers UNIT_ASSERT_EQUAL(cRef, bSubRef); - } + } Y_UNIT_TEST(TestImplicitConstructionFromContainer) { /* Just test compilation. */ diff --git a/util/generic/hash.h b/util/generic/hash.h index cb6672cf62..e46db21fa9 100644 --- a/util/generic/hash.h +++ b/util/generic/hash.h @@ -1461,7 +1461,7 @@ public: } template <class TAllocParam> explicit THashMap(TAllocParam* allocParam, size_type n = 0) - : rep(n, hasher(), key_equal(), allocParam) + : rep(n, hasher(), key_equal(), allocParam) { } explicit THashMap(size_type n) @@ -1509,13 +1509,13 @@ public: } THashMap(const std::initializer_list<std::pair<Key, T>>& list) - : rep(list.size(), hasher(), key_equal()) - { - for (const auto& v : list) { - rep.insert_unique_noresize(v); - } - } - + : rep(list.size(), hasher(), key_equal()) + { + for (const auto& v : list) { + rep.insert_unique_noresize(v); + } + } + // THashMap has implicit copy/move constructors and copy-/move-assignment operators // because its implementation is backed by THashTable. // See hash_ut.cpp @@ -1579,10 +1579,10 @@ public: return rep.insert_unique_noresize(obj); } - template <typename... Args> - std::pair<iterator, bool> emplace_noresize(Args&&... args) { - return rep.emplace_unique_noresize(std::forward<Args>(args)...); - } + template <typename... Args> + std::pair<iterator, bool> emplace_noresize(Args&&... args) { + return rep.emplace_unique_noresize(std::forward<Args>(args)...); + } template <class TheObj> iterator insert_direct(const TheObj& obj, const insert_ctx& ins) { diff --git a/util/generic/hash_set.h b/util/generic/hash_set.h index 309782304a..e8088cf23b 100644 --- a/util/generic/hash_set.h +++ b/util/generic/hash_set.h @@ -47,7 +47,7 @@ public: } template <class TT> explicit THashSet(TT* allocParam, size_type n = 0) - : rep(n, hasher(), key_equal(), allocParam) + : rep(n, hasher(), key_equal(), allocParam) { } explicit THashSet(size_type n) diff --git a/util/generic/hash_ut.cpp b/util/generic/hash_ut.cpp index 873a5ecebc..0551d58770 100644 --- a/util/generic/hash_ut.cpp +++ b/util/generic/hash_ut.cpp @@ -147,19 +147,19 @@ void THashTest::TestHMapConstructorsAndAssignments() { UNIT_ASSERT_VALUES_EQUAL(0, c2.size()); UNIT_ASSERT_VALUES_EQUAL(4, c3.size()); UNIT_ASSERT_VALUES_EQUAL(4, c3.at("four")); - + const container c4{ {"one", 1}, {"two", 2}, - {"three", 3}, + {"three", 3}, {"four", 4}, - }; - - UNIT_ASSERT_VALUES_EQUAL(4, c4.size()); - UNIT_ASSERT_VALUES_EQUAL(1, c4.at("one")); - UNIT_ASSERT_VALUES_EQUAL(2, c4.at("two")); - UNIT_ASSERT_VALUES_EQUAL(3, c4.at("three")); - UNIT_ASSERT_VALUES_EQUAL(4, c4.at("four")); + }; + + UNIT_ASSERT_VALUES_EQUAL(4, c4.size()); + UNIT_ASSERT_VALUES_EQUAL(1, c4.at("one")); + UNIT_ASSERT_VALUES_EQUAL(2, c4.at("two")); + UNIT_ASSERT_VALUES_EQUAL(3, c4.at("three")); + UNIT_ASSERT_VALUES_EQUAL(4, c4.at("four")); // non-existent values must be zero-initialized UNIT_ASSERT_VALUES_EQUAL(c1["nonexistent"], 0); @@ -1035,8 +1035,8 @@ void THashTest::TestHSetEmplaceDirect() { hash.emplace_direct(ins, 1); UNIT_ASSERT(hash.contains(0)); UNIT_ASSERT(!hash.contains(1)); -} - +} + void THashTest::TestNonCopyable() { struct TValue: public TNonCopyable { int value; diff --git a/util/generic/noncopyable.h b/util/generic/noncopyable.h index c4a1143f8b..c007934133 100644 --- a/util/generic/noncopyable.h +++ b/util/generic/noncopyable.h @@ -23,8 +23,8 @@ namespace NNonCopyable { // protection from unintended ADL }; struct TMoveOnly { - TMoveOnly(TMoveOnly&&) noexcept = default; - TMoveOnly& operator=(TMoveOnly&&) noexcept = default; + TMoveOnly(TMoveOnly&&) noexcept = default; + TMoveOnly& operator=(TMoveOnly&&) noexcept = default; TMoveOnly(const TMoveOnly&) = delete; TMoveOnly& operator=(const TMoveOnly&) = delete; diff --git a/util/generic/queue_ut.cpp b/util/generic/queue_ut.cpp index c747e33ac4..a33399e104 100644 --- a/util/generic/queue_ut.cpp +++ b/util/generic/queue_ut.cpp @@ -130,28 +130,28 @@ Y_UNIT_TEST_SUITE(TYQueueTest) { Y_UNIT_TEST(pqueue4) { TDeque<int> c; - c.push_back(42); - c.push_back(101); - c.push_back(69); - + c.push_back(42); + c.push_back(101); + c.push_back(69); + TPriorityQueue<int, TDeque<int>, TLess<int>> q(TLess<int>(), std::move(c)); - - UNIT_ASSERT(c.empty()); - - UNIT_ASSERT_EQUAL(q.size(), 3); - - UNIT_ASSERT(q.top() == 101); - - q.pop(); - UNIT_ASSERT(q.top() == 69); - - q.pop(); - UNIT_ASSERT(q.top() == 42); - - q.pop(); - UNIT_ASSERT(q.empty()); - } - + + UNIT_ASSERT(c.empty()); + + UNIT_ASSERT_EQUAL(q.size(), 3); + + UNIT_ASSERT(q.top() == 101); + + q.pop(); + UNIT_ASSERT(q.top() == 69); + + q.pop(); + UNIT_ASSERT(q.top() == 42); + + q.pop(); + UNIT_ASSERT(q.empty()); + } + Y_UNIT_TEST(queue1) { TQueue<int, TList<int>> q; diff --git a/util/generic/utility.h b/util/generic/utility.h index 36501499b7..43b98eeafc 100644 --- a/util/generic/utility.h +++ b/util/generic/utility.h @@ -30,18 +30,18 @@ constexpr const T& ClampVal(const T& val, const T& min, const T& max) { return val < min ? min : (max < val ? max : val); } -template <typename T = double, typename... Args> -static T Mean(const Args&... other) noexcept { - const auto numArgs = sizeof...(other); - - auto sum = T(); - for (const auto& v : {other...}) { - sum += v; - } - - return sum / numArgs; -} - +template <typename T = double, typename... Args> +static T Mean(const Args&... other) noexcept { + const auto numArgs = sizeof...(other); + + auto sum = T(); + for (const auto& v : {other...}) { + sum += v; + } + + return sum / numArgs; +} + template <class T> static inline void Zero(T& t) noexcept { memset((void*)&t, 0, sizeof(t)); diff --git a/util/generic/utility_ut.cpp b/util/generic/utility_ut.cpp index c2893dca03..8e9d5afff9 100644 --- a/util/generic/utility_ut.cpp +++ b/util/generic/utility_ut.cpp @@ -1,5 +1,5 @@ #include "utility.h" -#include "ymath.h" +#include "ymath.h" #include <library/cpp/testing/unittest/registar.h> @@ -66,7 +66,7 @@ Y_UNIT_TEST_SUITE(TUtilityTest) { UNIT_ASSERT_VALUES_EQUAL(Min(TUnorderedTag{"first"}, TUnorderedTag{"second"}, TUnorderedTag{"third"}).Tag, "first"); UNIT_ASSERT_VALUES_EQUAL(Max(TUnorderedTag{"first"}, TUnorderedTag{"second"}, TUnorderedTag{"third"}).Tag, "first"); } - + Y_UNIT_TEST(TestMean) { UNIT_ASSERT_EQUAL(Mean(5), 5); UNIT_ASSERT_EQUAL(Mean(1, 2, 3), 2); |