diff options
author | Ruslan Kovalev <ruslan.a.kovalev@gmail.com> | 2022-02-10 16:46:44 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:46:44 +0300 |
commit | 59e19371de37995fcb36beb16cd6ec030af960bc (patch) | |
tree | fa68e36093ebff8b805462e9e6d331fe9d348214 /util/generic | |
parent | 89db6fe2fe2c32d2a832ddfeb04e8d078e301084 (diff) | |
download | ydb-59e19371de37995fcb36beb16cd6ec030af960bc.tar.gz |
Restoring authorship annotation for Ruslan Kovalev <ruslan.a.kovalev@gmail.com>. Commit 1 of 2.
Diffstat (limited to 'util/generic')
35 files changed, 97 insertions, 97 deletions
diff --git a/util/generic/algorithm.h b/util/generic/algorithm.h index badfb88993..3d73275c31 100644 --- a/util/generic/algorithm.h +++ b/util/generic/algorithm.h @@ -1,4 +1,4 @@ -#pragma once +#pragma once #include "is_in.h" #include "utility.h" @@ -308,11 +308,11 @@ static inline T Unique(T f, T l, P p) { return std::unique(f, l, p); } -template <class T, class TGetKey> -static inline T UniqueBy(T f, T l, const TGetKey& getKey) { - return Unique(f, l, [&](auto&& left, auto&& right) { return getKey(left) == getKey(right); }); -} - +template <class T, class TGetKey> +static inline T UniqueBy(T f, T l, const TGetKey& getKey) { + return Unique(f, l, [&](auto&& left, auto&& right) { return getKey(left) == getKey(right); }); +} + template <class C> void SortUnique(C& c) { Sort(c.begin(), c.end()); @@ -325,18 +325,18 @@ void SortUnique(C& c, Cmp cmp) { c.erase(Unique(c.begin(), c.end()), c.end()); } -template <class C, class TGetKey> -void SortUniqueBy(C& c, const TGetKey& getKey) { - SortBy(c, getKey); +template <class C, class TGetKey> +void SortUniqueBy(C& c, const TGetKey& getKey) { + SortBy(c, getKey); c.erase(UniqueBy(c.begin(), c.end(), getKey), c.end()); -} - -template <class C, class TGetKey> -void StableSortUniqueBy(C& c, const TGetKey& getKey) { - StableSortBy(c, getKey); +} + +template <class C, class TGetKey> +void StableSortUniqueBy(C& c, const TGetKey& getKey) { + StableSortBy(c, getKey); c.erase(UniqueBy(c.begin(), c.end(), getKey), c.end()); -} - +} + template <class C, class TValue> void Erase(C& c, const TValue& value) { c.erase(std::remove(c.begin(), c.end(), value), c.end()); diff --git a/util/generic/algorithm_ut.cpp b/util/generic/algorithm_ut.cpp index 8d732fcc0c..a26e70a3d6 100644 --- a/util/generic/algorithm_ut.cpp +++ b/util/generic/algorithm_ut.cpp @@ -517,18 +517,18 @@ Y_UNIT_TEST_SUITE(TAlgorithm) { Y_UNIT_TEST(SortUniqueByTest) { TVector<int> collection = {404, 101, 101, 203, 101, 203, 404}; - StableSortUniqueBy(collection, [](int x) { return x / 100; }); + StableSortUniqueBy(collection, [](int x) { return x / 100; }); TVector<int> expected = {101, 203, 404}; - UNIT_ASSERT_VALUES_EQUAL(collection, expected); - } - + UNIT_ASSERT_VALUES_EQUAL(collection, expected); + } + Y_UNIT_TEST(StableSortUniqueByTest) { TVector<int> collection = {404, 101, 106, 203, 102, 205, 401}; - StableSortUniqueBy(collection, [](int x) { return x / 100; }); + StableSortUniqueBy(collection, [](int x) { return x / 100; }); TVector<int> expected = {101, 203, 404}; - UNIT_ASSERT_VALUES_EQUAL(collection, expected); - } - + UNIT_ASSERT_VALUES_EQUAL(collection, expected); + } + Y_UNIT_TEST(IotaTest) { TVector<int> v(10); diff --git a/util/generic/bitmap.h b/util/generic/bitmap.h index f77d182460..da5dcbc74d 100644 --- a/util/generic/bitmap.h +++ b/util/generic/bitmap.h @@ -1,4 +1,4 @@ -#pragma once +#pragma once #include "fwd.h" #include "ptr.h" diff --git a/util/generic/bitops.h b/util/generic/bitops.h index 2db15fc59b..cbe342f170 100644 --- a/util/generic/bitops.h +++ b/util/generic/bitops.h @@ -1,4 +1,4 @@ -#pragma once +#pragma once #include "ylimits.h" #include "typelist.h" diff --git a/util/generic/buffer.h b/util/generic/buffer.h index 9576467404..7e6c3d3a99 100644 --- a/util/generic/buffer.h +++ b/util/generic/buffer.h @@ -1,4 +1,4 @@ -#pragma once +#pragma once #include "utility.h" @@ -8,7 +8,7 @@ #include <cstring> -class TBuffer { +class TBuffer { public: using TIterator = char*; using TConstIterator = const char*; @@ -23,7 +23,7 @@ public: { *this = b; } - + TBuffer(TBuffer&& b) noexcept; TBuffer& operator=(TBuffer&& b) noexcept; @@ -34,7 +34,7 @@ public: } return *this; } - + ~TBuffer(); inline void Clear() noexcept { diff --git a/util/generic/cast.h b/util/generic/cast.h index 0d4a41f385..0ca257a7a2 100644 --- a/util/generic/cast.h +++ b/util/generic/cast.h @@ -1,4 +1,4 @@ -#pragma once +#pragma once #include "typetraits.h" #include "yexception.h" diff --git a/util/generic/deque.h b/util/generic/deque.h index 2dabaf3177..2079c70ba5 100644 --- a/util/generic/deque.h +++ b/util/generic/deque.h @@ -1,4 +1,4 @@ -#pragma once +#pragma once #include "fwd.h" diff --git a/util/generic/hash.h b/util/generic/hash.h index e46db21fa9..69ba84dec6 100644 --- a/util/generic/hash.h +++ b/util/generic/hash.h @@ -701,7 +701,7 @@ public: *ins = tmp; ++num_elements; return iterator(tmp); - } + } template <typename... Args> std::pair<iterator, bool> emplace_unique(Args&&... args) { @@ -1616,7 +1616,7 @@ public: const_iterator find(const TheKey& key) const { return rep.find(key); } - + template <class TheKey> iterator find(const TheKey& key, insert_ctx& ins) { return rep.find_i(key, ins); diff --git a/util/generic/intrlist.h b/util/generic/intrlist.h index b5d3f2051b..becab74c4f 100644 --- a/util/generic/intrlist.h +++ b/util/generic/intrlist.h @@ -1,4 +1,4 @@ -#pragma once +#pragma once #include "utility.h" diff --git a/util/generic/iterator.h b/util/generic/iterator.h index 19e9d20976..1a9a856132 100644 --- a/util/generic/iterator.h +++ b/util/generic/iterator.h @@ -1,4 +1,4 @@ -#pragma once +#pragma once #include <iterator> #include <utility> diff --git a/util/generic/list.h b/util/generic/list.h index 7b0b8ffc72..df16951531 100644 --- a/util/generic/list.h +++ b/util/generic/list.h @@ -1,4 +1,4 @@ -#pragma once +#pragma once #include "fwd.h" diff --git a/util/generic/map.h b/util/generic/map.h index b5001b56c0..3a8f4bc2a9 100644 --- a/util/generic/map.h +++ b/util/generic/map.h @@ -1,4 +1,4 @@ -#pragma once +#pragma once #include "fwd.h" #include "mapfindptr.h" diff --git a/util/generic/map_ut.cpp b/util/generic/map_ut.cpp index 79e832b024..e6bce5ebab 100644 --- a/util/generic/map_ut.cpp +++ b/util/generic/map_ut.cpp @@ -1,40 +1,40 @@ #include "map.h" #include <library/cpp/testing/unittest/registar.h> -#include <util/memory/pool.h> +#include <util/memory/pool.h> #include <algorithm> Y_UNIT_TEST_SUITE(TYMapTest) { template <typename TAlloc> void DoTestMap1(TMap<char, int, TLess<char>, TAlloc>& m); - + template <typename TAlloc> void DoTestMMap1(TMultiMap<char, int, TLess<char>, TAlloc>& mm); - + Y_UNIT_TEST(TestMap1) { { TMap<char, int, TLess<char>> m; DoTestMap1(m); - } + } { TMemoryPool p(100); TMap<char, int, TLess<char>, TPoolAllocator> m(&p); DoTestMap1(m); } } - + Y_UNIT_TEST(TestMMap1) { { TMultiMap<char, int, TLess<char>> mm; DoTestMMap1(mm); - } + } { TMemoryPool p(100); TMultiMap<char, int, TLess<char>, TPoolAllocator> mm(&p); DoTestMMap1(mm); } } - + template <typename TAlloc> void DoTestMap1(TMap<char, int, TLess<char>, TAlloc>& m) { using maptype = TMap<char, int, TLess<char>, TAlloc>; @@ -69,7 +69,7 @@ Y_UNIT_TEST_SUITE(TYMapTest) { template <typename TAlloc> void DoTestMMap1(TMultiMap<char, int, TLess<char>, TAlloc>& m) { using mmap = TMultiMap<char, int, TLess<char>, TAlloc>; - + UNIT_ASSERT(m.count('X') == 0); m.insert(std::pair<const char, int>('X', 10)); // Standard way. diff --git a/util/generic/maybe.h b/util/generic/maybe.h index 34d21aebcd..a897490ca6 100644 --- a/util/generic/maybe.h +++ b/util/generic/maybe.h @@ -1,4 +1,4 @@ -#pragma once +#pragma once #include <utility> diff --git a/util/generic/maybe_ut.cpp b/util/generic/maybe_ut.cpp index 2c1a425c5e..f11bdcb730 100644 --- a/util/generic/maybe_ut.cpp +++ b/util/generic/maybe_ut.cpp @@ -225,20 +225,20 @@ Y_UNIT_TEST_SUITE(TMaybeTest) { Y_UNIT_TEST(TestGetOr) { UNIT_ASSERT_VALUES_EQUAL(TMaybe<TString>().GetOrElse("xxx"), TString("xxx")); UNIT_ASSERT_VALUES_EQUAL(TMaybe<TString>("yyy").GetOrElse("xxx"), TString("yyy")); - - { + + { TString xxx = "xxx"; UNIT_ASSERT_VALUES_EQUAL(TMaybe<TString>().GetOrElse(xxx).append('x'), TString("xxxx")); - UNIT_ASSERT_VALUES_EQUAL(xxx, "xxxx"); - } - - { + UNIT_ASSERT_VALUES_EQUAL(xxx, "xxxx"); + } + + { TString xxx = "xxx"; UNIT_ASSERT_VALUES_EQUAL(TMaybe<TString>("yyy").GetOrElse(xxx).append('x'), TString("yyyx")); - UNIT_ASSERT_VALUES_EQUAL(xxx, "xxx"); - } - } - + UNIT_ASSERT_VALUES_EQUAL(xxx, "xxx"); + } + } + /* == != diff --git a/util/generic/noncopyable.h b/util/generic/noncopyable.h index c007934133..a50961b7b6 100644 --- a/util/generic/noncopyable.h +++ b/util/generic/noncopyable.h @@ -1,4 +1,4 @@ -#pragma once +#pragma once /** * @class TNonCopyable @@ -21,18 +21,18 @@ namespace NNonCopyable { // protection from unintended ADL TNonCopyable() = default; ~TNonCopyable() = default; }; - + struct TMoveOnly { TMoveOnly(TMoveOnly&&) noexcept = default; TMoveOnly& operator=(TMoveOnly&&) noexcept = default; - - TMoveOnly(const TMoveOnly&) = delete; - TMoveOnly& operator=(const TMoveOnly&) = delete; - - TMoveOnly() = default; - ~TMoveOnly() = default; - }; + + TMoveOnly(const TMoveOnly&) = delete; + TMoveOnly& operator=(const TMoveOnly&) = delete; + + TMoveOnly() = default; + ~TMoveOnly() = default; + }; } using TNonCopyable = NNonCopyable::TNonCopyable; -using TMoveOnly = NNonCopyable::TMoveOnly; +using TMoveOnly = NNonCopyable::TMoveOnly; diff --git a/util/generic/ptr.h b/util/generic/ptr.h index 19db0e3ec5..043d264316 100644 --- a/util/generic/ptr.h +++ b/util/generic/ptr.h @@ -1,4 +1,4 @@ -#pragma once +#pragma once #include "fwd.h" #include "utility.h" @@ -41,13 +41,13 @@ inline void CheckedArrayDelete(T* t) { delete[] t; } -class TNoAction { +class TNoAction { public: template <class T> static inline void Destroy(T*) noexcept { } -}; - +}; + class TDelete { public: template <class T> diff --git a/util/generic/refcount.h b/util/generic/refcount.h index 966e853b77..10460ad632 100644 --- a/util/generic/refcount.h +++ b/util/generic/refcount.h @@ -1,4 +1,4 @@ -#pragma once +#pragma once #include <util/system/guard.h> #include <util/system/atomic.h> diff --git a/util/generic/set.h b/util/generic/set.h index 4c437ca26f..373f42f984 100644 --- a/util/generic/set.h +++ b/util/generic/set.h @@ -1,4 +1,4 @@ -#pragma once +#pragma once #include "fwd.h" diff --git a/util/generic/singleton.h b/util/generic/singleton.h index f5fa047f5c..bedfa7adbe 100644 --- a/util/generic/singleton.h +++ b/util/generic/singleton.h @@ -1,4 +1,4 @@ -#pragma once +#pragma once #include <util/system/atexit.h> #include <util/system/atomic.h> diff --git a/util/generic/stack.h b/util/generic/stack.h index dbcbf2b5c9..c07c58faa2 100644 --- a/util/generic/stack.h +++ b/util/generic/stack.h @@ -1,4 +1,4 @@ -#pragma once +#pragma once #include "fwd.h" #include "deque.h" diff --git a/util/generic/strbase.h b/util/generic/strbase.h index ab39fc7537..050a32bfb4 100644 --- a/util/generic/strbase.h +++ b/util/generic/strbase.h @@ -1,4 +1,4 @@ -#pragma once +#pragma once // Some of these includes are just a legacy from previous implementation. // We don't need them here, but removing them is tricky because it breaks all diff --git a/util/generic/strbuf.h b/util/generic/strbuf.h index 70b9360d58..18576be409 100644 --- a/util/generic/strbuf.h +++ b/util/generic/strbuf.h @@ -1,4 +1,4 @@ -#pragma once +#pragma once #include "fwd.h" #include "strbase.h" @@ -345,14 +345,14 @@ public: } public: - // returns tail, including pos + // returns tail, including pos TdSelf SplitOffAt(size_t pos) { const TdSelf tok = SubStr(pos); Trunc(pos); return tok; } - // returns head, tail includes pos + // returns head, tail includes pos TdSelf NextTokAt(size_t pos) { const TdSelf tok = Head(pos); Skip(pos); diff --git a/util/generic/strfcpy.h b/util/generic/strfcpy.h index 8a95bc3df2..b44f797185 100644 --- a/util/generic/strfcpy.h +++ b/util/generic/strfcpy.h @@ -1,4 +1,4 @@ -#pragma once +#pragma once /* * strfcpy is a faster version of strlcpy(). diff --git a/util/generic/string.h b/util/generic/string.h index 8cd8aa6917..9375f5a3d6 100644 --- a/util/generic/string.h +++ b/util/generic/string.h @@ -1,4 +1,4 @@ -#pragma once +#pragma once #include <cstddef> #include <cstring> diff --git a/util/generic/typelist.h b/util/generic/typelist.h index 5ce26ab97c..a964fa3071 100644 --- a/util/generic/typelist.h +++ b/util/generic/typelist.h @@ -1,4 +1,4 @@ -#pragma once +#pragma once #include <util/system/types.h> diff --git a/util/generic/typetraits.h b/util/generic/typetraits.h index d165bd1a06..2811cf81ab 100644 --- a/util/generic/typetraits.h +++ b/util/generic/typetraits.h @@ -1,4 +1,4 @@ -#pragma once +#pragma once #include "va_args.h" diff --git a/util/generic/utility.h b/util/generic/utility.h index 43b98eeafc..bb0534d297 100644 --- a/util/generic/utility.h +++ b/util/generic/utility.h @@ -1,4 +1,4 @@ -#pragma once +#pragma once #include "typetraits.h" diff --git a/util/generic/variant.h b/util/generic/variant.h index 749fc75090..9c88969623 100644 --- a/util/generic/variant.h +++ b/util/generic/variant.h @@ -1,18 +1,18 @@ #pragma once #include "hash.h" - + #include <variant> - -template <class... Ts> + +template <class... Ts> struct THash<std::variant<Ts...>> { -public: +public: size_t operator()(const std::variant<Ts...>& v) const noexcept { return CombineHashes( IntHash(v.index()), v.valueless_by_exception() ? 0 : std::visit([](const auto& value) { return ComputeHash(value); }, v)); - } -}; + } +}; template <> struct THash<std::monostate> { diff --git a/util/generic/vector.h b/util/generic/vector.h index a5b258955a..d635ad773d 100644 --- a/util/generic/vector.h +++ b/util/generic/vector.h @@ -1,4 +1,4 @@ -#pragma once +#pragma once #include "fwd.h" #include "reserve.h" diff --git a/util/generic/yexception.h b/util/generic/yexception.h index b0c604e8c4..cde2c87c7b 100644 --- a/util/generic/yexception.h +++ b/util/generic/yexception.h @@ -1,7 +1,7 @@ -#pragma once +#pragma once #include "bt_exception.h" -#include "strbuf.h" +#include "strbuf.h" #include "string.h" #include "utility.h" #include "va_args.h" diff --git a/util/generic/yexception_ut.h b/util/generic/yexception_ut.h index acf6f27e99..ce5546cda4 100644 --- a/util/generic/yexception_ut.h +++ b/util/generic/yexception_ut.h @@ -1,4 +1,4 @@ -#pragma once +#pragma once #ifdef __cplusplus extern "C" { diff --git a/util/generic/ylimits.h b/util/generic/ylimits.h index fe42b4dfc0..5f02998c56 100644 --- a/util/generic/ylimits.h +++ b/util/generic/ylimits.h @@ -1,4 +1,4 @@ -#pragma once +#pragma once #include <limits> diff --git a/util/generic/ymath.h b/util/generic/ymath.h index 9ff9ae2abe..3a9078e6a6 100644 --- a/util/generic/ymath.h +++ b/util/generic/ymath.h @@ -1,4 +1,4 @@ -#pragma once +#pragma once #include <util/system/yassert.h> #include <util/system/defaults.h> diff --git a/util/generic/ymath_ut.cpp b/util/generic/ymath_ut.cpp index 29190b55eb..87fd0ad0fa 100644 --- a/util/generic/ymath_ut.cpp +++ b/util/generic/ymath_ut.cpp @@ -1,4 +1,4 @@ -#include "bitops.h" +#include "bitops.h" #include "ymath.h" #include <library/cpp/testing/unittest/registar.h> |