diff options
author | mstebelev <mstebelev@yandex-team.ru> | 2022-02-10 16:47:17 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:47:17 +0300 |
commit | 5a176099114d03d5669e95a55a3a514bd24dd8b1 (patch) | |
tree | 13d2cd27a59ccff4e44d7c7f530f923483f82267 /library | |
parent | 3c1fe03778c21d7aa4a5c4a4433ca611dbf2f785 (diff) | |
download | ydb-5a176099114d03d5669e95a55a3a514bd24dd8b1.tar.gz |
Restoring authorship annotation for <mstebelev@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'library')
-rw-r--r-- | library/cpp/iterator/filtering.h | 124 | ||||
-rw-r--r-- | library/cpp/iterator/mapped.h | 152 | ||||
-rw-r--r-- | library/cpp/iterator/ut/filtering_ut.cpp | 8 | ||||
-rw-r--r-- | library/cpp/iterator/ut/mapped_ut.cpp | 12 | ||||
-rw-r--r-- | library/cpp/iterator/ut/ya.make | 14 | ||||
-rw-r--r-- | library/cpp/iterator/ya.make | 8 | ||||
-rw-r--r-- | library/cpp/json/json_reader.h | 2 | ||||
-rw-r--r-- | library/cpp/protobuf/json/json2proto.h | 12 | ||||
-rw-r--r-- | library/cpp/streams/ya.make | 4 | ||||
-rw-r--r-- | library/python/testing/import_test/import_test.py | 16 | ||||
-rw-r--r-- | library/python/testing/yatest_lib/external.py | 6 | ||||
-rw-r--r-- | library/python/ya.make | 24 |
12 files changed, 191 insertions, 191 deletions
diff --git a/library/cpp/iterator/filtering.h b/library/cpp/iterator/filtering.h index c28e3bc6c4..c99428b5f1 100644 --- a/library/cpp/iterator/filtering.h +++ b/library/cpp/iterator/filtering.h @@ -1,61 +1,61 @@ -#pragma once - +#pragma once + #include <util/generic/iterator_range.h> #include <util/generic/store_policy.h> -#include <iterator> - - -template <class TIterator, class TCondition> -class TFilteringIterator { -public: - using TSelf = TFilteringIterator<TIterator, TCondition>; - - using difference_type = typename std::iterator_traits<TIterator>::difference_type; - using value_type = typename std::iterator_traits<TIterator>::value_type; - using reference = typename std::iterator_traits<TIterator>::reference; - using pointer = typename std::iterator_traits<TIterator>::pointer; - using iterator_category = std::forward_iterator_tag; - - TFilteringIterator(TIterator it, TIterator last, const TCondition& condition) - : Iter(it) - , Last(last) +#include <iterator> + + +template <class TIterator, class TCondition> +class TFilteringIterator { +public: + using TSelf = TFilteringIterator<TIterator, TCondition>; + + using difference_type = typename std::iterator_traits<TIterator>::difference_type; + using value_type = typename std::iterator_traits<TIterator>::value_type; + using reference = typename std::iterator_traits<TIterator>::reference; + using pointer = typename std::iterator_traits<TIterator>::pointer; + using iterator_category = std::forward_iterator_tag; + + TFilteringIterator(TIterator it, TIterator last, const TCondition& condition) + : Iter(it) + , Last(last) , Condition(condition) - { - Grep(); - } - - TSelf& operator++() { - ++Iter; - Grep(); - return *this; - } - - decltype(auto) operator*() const { - return *Iter; - } - - pointer operator->() const { - return &*Iter; - } - - bool operator==(const TSelf& other) const { - return Iter == other.Iter; - } - bool operator!=(const TSelf& other) const { - return Iter != other.Iter; - } - -private: - void Grep() { - while (Iter != Last && !Condition(*Iter)) { - ++Iter; - } - } - TIterator Iter; - TIterator Last; - TCondition Condition; -}; - + { + Grep(); + } + + TSelf& operator++() { + ++Iter; + Grep(); + return *this; + } + + decltype(auto) operator*() const { + return *Iter; + } + + pointer operator->() const { + return &*Iter; + } + + bool operator==(const TSelf& other) const { + return Iter == other.Iter; + } + bool operator!=(const TSelf& other) const { + return Iter != other.Iter; + } + +private: + void Grep() { + while (Iter != Last && !Condition(*Iter)) { + ++Iter; + } + } + TIterator Iter; + TIterator Last; + TCondition Condition; +}; + template <class TContainer, class TCondition> class TFilteringRange { @@ -91,12 +91,12 @@ private: }; -template <class TIterator, class TCondition> -auto MakeFilteringRange(TIterator begin, TIterator end, const TCondition& condition) { - return MakeIteratorRange(TFilteringIterator<TIterator, TCondition>(begin, end, condition), TFilteringIterator<TIterator, TCondition>(end, end, condition)); -} - -template <class TContainer, class TCondition> +template <class TIterator, class TCondition> +auto MakeFilteringRange(TIterator begin, TIterator end, const TCondition& condition) { + return MakeIteratorRange(TFilteringIterator<TIterator, TCondition>(begin, end, condition), TFilteringIterator<TIterator, TCondition>(end, end, condition)); +} + +template <class TContainer, class TCondition> auto MakeFilteringRange(TContainer&& container, TCondition&& condition) { return TFilteringRange<TContainer, TCondition>(std::forward<TContainer>(container), std::forward<TCondition>(condition)); -} +} diff --git a/library/cpp/iterator/mapped.h b/library/cpp/iterator/mapped.h index 6c5e763184..255ebb1803 100644 --- a/library/cpp/iterator/mapped.h +++ b/library/cpp/iterator/mapped.h @@ -1,8 +1,8 @@ -#pragma once - -#include <util/generic/iterator_range.h> +#pragma once + +#include <util/generic/iterator_range.h> #include <util/generic/store_policy.h> - + #include <iterator> @@ -15,83 +15,83 @@ namespace NIteratorPrivate { }; -template <class TIterator, class TMapper> -class TMappedIterator { +template <class TIterator, class TMapper> +class TMappedIterator { protected: - using TSelf = TMappedIterator<TIterator, TMapper>; - using TSrcPointerType = typename std::iterator_traits<TIterator>::reference; + using TSelf = TMappedIterator<TIterator, TMapper>; + using TSrcPointerType = typename std::iterator_traits<TIterator>::reference; using TValue = typename std::invoke_result_t<TMapper, TSrcPointerType>; public: - using difference_type = std::ptrdiff_t; - using value_type = TValue; - using reference = TValue&; - using pointer = std::remove_reference_t<TValue>*; + using difference_type = std::ptrdiff_t; + using value_type = TValue; + using reference = TValue&; + using pointer = std::remove_reference_t<TValue>*; using iterator_category = std::conditional_t<NIteratorPrivate::HasRandomAccess<TIterator>(), std::random_access_iterator_tag, std::input_iterator_tag>; - + TMappedIterator(TIterator it, TMapper mapper) - : Iter(it) + : Iter(it) , Mapper(std::move(mapper)) - { - } - - TSelf& operator++() { - ++Iter; - return *this; - } - TSelf& operator--() { - --Iter; - return *this; - } + { + } + + TSelf& operator++() { + ++Iter; + return *this; + } + TSelf& operator--() { + --Iter; + return *this; + } TValue operator*() { return Mapper((*Iter)); } - TValue operator*() const { - return Mapper((*Iter)); - } - - pointer operator->() const { - return &(Mapper((*Iter))); - } - - TValue operator[](difference_type n) const { - return Mapper(*(Iter + n)); - } - TSelf& operator+=(difference_type n) { - Iter += n; - return *this; - } - TSelf& operator-=(difference_type n) { - Iter -= n; - return *this; - } - TSelf operator+(difference_type n) const { - return TSelf(Iter + n, Mapper); - } + TValue operator*() const { + return Mapper((*Iter)); + } + + pointer operator->() const { + return &(Mapper((*Iter))); + } + + TValue operator[](difference_type n) const { + return Mapper(*(Iter + n)); + } + TSelf& operator+=(difference_type n) { + Iter += n; + return *this; + } + TSelf& operator-=(difference_type n) { + Iter -= n; + return *this; + } + TSelf operator+(difference_type n) const { + return TSelf(Iter + n, Mapper); + } TSelf operator-(difference_type n) const { return TSelf(Iter - n, Mapper); } - difference_type operator-(const TSelf& other) const { - return Iter - other.Iter; - } - bool operator==(const TSelf& other) const { - return Iter == other.Iter; - } - bool operator!=(const TSelf& other) const { - return Iter != other.Iter; - } - bool operator>(const TSelf& other) const { - return Iter > other.Iter; - } - bool operator<(const TSelf& other) const { - return Iter < other.Iter; - } - -private: - TIterator Iter; + difference_type operator-(const TSelf& other) const { + return Iter - other.Iter; + } + bool operator==(const TSelf& other) const { + return Iter == other.Iter; + } + bool operator!=(const TSelf& other) const { + return Iter != other.Iter; + } + bool operator>(const TSelf& other) const { + return Iter > other.Iter; + } + bool operator<(const TSelf& other) const { + return Iter < other.Iter; + } + +private: + TIterator Iter; TMapper Mapper; -}; - +}; + template <class TContainer, class TMapper> class TInputMappedRange { @@ -173,21 +173,21 @@ public: } }; -template <class TIterator, class TMapper> +template <class TIterator, class TMapper> TMappedIterator<TIterator, TMapper> MakeMappedIterator(TIterator iter, TMapper mapper) { return {iter, mapper}; -} - -template <class TIterator, class TMapper> +} + +template <class TIterator, class TMapper> auto MakeMappedRange(TIterator begin, TIterator end, TMapper mapper) { - return MakeIteratorRange(MakeMappedIterator(begin, mapper), MakeMappedIterator(end, mapper)); -} - -template <class TContainer, class TMapper> + return MakeIteratorRange(MakeMappedIterator(begin, mapper), MakeMappedIterator(end, mapper)); +} + +template <class TContainer, class TMapper> auto MakeMappedRange(TContainer&& container, TMapper&& mapper) { if constexpr (NIteratorPrivate::HasRandomAccess<decltype(std::begin(container))>()) { return TRandomAccessMappedRange<TContainer, TMapper>(std::forward<TContainer>(container), std::forward<TMapper>(mapper)); } else { return TInputMappedRange<TContainer, TMapper>(std::forward<TContainer>(container), std::forward<TMapper>(mapper)); } -} +} diff --git a/library/cpp/iterator/ut/filtering_ut.cpp b/library/cpp/iterator/ut/filtering_ut.cpp index 60c2044698..1837e1e280 100644 --- a/library/cpp/iterator/ut/filtering_ut.cpp +++ b/library/cpp/iterator/ut/filtering_ut.cpp @@ -1,7 +1,7 @@ #include <library/cpp/iterator/filtering.h> - + #include <library/cpp/testing/gtest/gtest.h> - + #include <util/generic/vector.h> using namespace testing; @@ -33,9 +33,9 @@ TEST(Filtering, TMutableFilteringRangeTest) { TVector<int> x = {1, 2, 3, 4, 5}; for (auto& y : MakeFilteringRange(x, [](int x) { return x % 2 == 0; })) { y = 7; - } + } EXPECT_THAT( x, ElementsAre(1, 7, 3, 7, 5) ); -} +} diff --git a/library/cpp/iterator/ut/mapped_ut.cpp b/library/cpp/iterator/ut/mapped_ut.cpp index 440cd37945..94b686c119 100644 --- a/library/cpp/iterator/ut/mapped_ut.cpp +++ b/library/cpp/iterator/ut/mapped_ut.cpp @@ -1,10 +1,10 @@ #include <library/cpp/iterator/mapped.h> - + #include <library/cpp/testing/gtest/gtest.h> - + #include <util/generic/map.h> #include <util/generic/vector.h> - + using namespace testing; TEST(TIterator, TMappedIteratorTest) { @@ -45,7 +45,7 @@ TEST(TIterator, TOwningMappedMethodTest) { TVector<std::pair<int, int>>{std::make_pair(1, 2), std::make_pair(3, 4)}, [](auto& point) -> int& { return point.first; - } + } ); EXPECT_EQ(range[0], 1); range[0] += 1; @@ -54,8 +54,8 @@ TEST(TIterator, TOwningMappedMethodTest) { EXPECT_EQ(range[0], 3); for (int& y : range) { y += 7; - } + } EXPECT_EQ(*range.begin(), 10); EXPECT_EQ(*(range.begin() + 1), 10); -} +} diff --git a/library/cpp/iterator/ut/ya.make b/library/cpp/iterator/ut/ya.make index 601e5663b9..1a457541b4 100644 --- a/library/cpp/iterator/ut/ya.make +++ b/library/cpp/iterator/ut/ya.make @@ -1,18 +1,18 @@ GTEST() - + PEERDIR( library/cpp/iterator ) OWNER(g:util) - -SRCS( - filtering_ut.cpp + +SRCS( + filtering_ut.cpp functools_ut.cpp iterate_keys_ut.cpp iterate_values_ut.cpp mapped_ut.cpp zip_ut.cpp -) - -END() +) + +END() diff --git a/library/cpp/iterator/ya.make b/library/cpp/iterator/ya.make index 1ba1ffb411..226858b8c5 100644 --- a/library/cpp/iterator/ya.make +++ b/library/cpp/iterator/ya.make @@ -1,7 +1,7 @@ OWNER(g:util) - -LIBRARY() - + +LIBRARY() + SRCS( cartesian_product.cpp concatenate.cpp @@ -14,6 +14,6 @@ SRCS( zip.cpp ) -END() +END() RECURSE_FOR_TESTS(ut) diff --git a/library/cpp/json/json_reader.h b/library/cpp/json/json_reader.h index b673788330..b9722e31fc 100644 --- a/library/cpp/json/json_reader.h +++ b/library/cpp/json/json_reader.h @@ -43,7 +43,7 @@ namespace NJson { bool ReadJson(IInputStream* in, bool allowComments, TJsonCallbacks* callbacks); bool ReadJson(IInputStream* in, bool allowComments, bool allowEscapedApostrophe, TJsonCallbacks* callbacks); bool ReadJson(IInputStream* in, const TJsonReaderConfig* config, TJsonCallbacks* callbacks); - + enum ReaderConfigFlags { COMMENTS = 0b100, VALIDATE = 0b010, diff --git a/library/cpp/protobuf/json/json2proto.h b/library/cpp/protobuf/json/json2proto.h index 4c33498dfa..5d7f10db72 100644 --- a/library/cpp/protobuf/json/json2proto.h +++ b/library/cpp/protobuf/json/json2proto.h @@ -175,12 +175,12 @@ namespace NProtobufJson { } /// @throw yexception - inline void Json2Proto(IInputStream& in, google::protobuf::Message& proto, - const TJson2ProtoConfig& config = TJson2ProtoConfig()) { - Json2Proto(TStringBuf(in.ReadAll()), proto, config); - } - - /// @throw yexception + inline void Json2Proto(IInputStream& in, google::protobuf::Message& proto, + const TJson2ProtoConfig& config = TJson2ProtoConfig()) { + Json2Proto(TStringBuf(in.ReadAll()), proto, config); + } + + /// @throw yexception template <typename T> T Json2Proto(IInputStream& in, const NJson::TJsonReaderConfig& readerConfig, const TJson2ProtoConfig& config = TJson2ProtoConfig()) { diff --git a/library/cpp/streams/ya.make b/library/cpp/streams/ya.make index 7426a874ee..6c3a0559cf 100644 --- a/library/cpp/streams/ya.make +++ b/library/cpp/streams/ya.make @@ -15,8 +15,8 @@ RECURSE( lz/ut lzma lzma/ut - lzop - lzop/ut + lzop + lzop/ut special special/ut xz diff --git a/library/python/testing/import_test/import_test.py b/library/python/testing/import_test/import_test.py index 3e3b7234ef..b9a3013b98 100644 --- a/library/python/testing/import_test/import_test.py +++ b/library/python/testing/import_test/import_test.py @@ -5,18 +5,18 @@ import re import sys import time import traceback - + import __res from __res import importer def check_imports(no_check=(), extra=(), skip_func=None, py_main=None): - """ - tests all bundled modules are importable - just add - "PEERDIR(library/python/import_test)" to your CMakeLists.txt and - "from import_test import test_imports" to your python test source file. - """ + """ + tests all bundled modules are importable + just add + "PEERDIR(library/python/import_test)" to your CMakeLists.txt and + "from import_test import test_imports" to your python test source file. + """ str_ = lambda s: s if not isinstance(b'', str): str_ = lambda s: s.decode('UTF-8') @@ -33,7 +33,7 @@ def check_imports(no_check=(), extra=(), skip_func=None, py_main=None): failed = [] import_times = {} - + norm = lambda s: s[:-9] if s.endswith('.__init__') else s modules = sys.extra_modules | set(extra) diff --git a/library/python/testing/yatest_lib/external.py b/library/python/testing/yatest_lib/external.py index 39113230d9..5c59a09d34 100644 --- a/library/python/testing/yatest_lib/external.py +++ b/library/python/testing/yatest_lib/external.py @@ -6,7 +6,7 @@ import copy import logging from . import tools -from datetime import date, datetime +from datetime import date, datetime import enum import six @@ -73,8 +73,8 @@ def serialize(value): return val if is_external(val): return dict(val) - if isinstance(val, (date, datetime)): - return repr(val) + if isinstance(val, (date, datetime)): + return repr(val) if is_coroutine(val): return None raise ValueError("Cannot serialize value '{}' of type {}".format(val, type(val))) diff --git a/library/python/ya.make b/library/python/ya.make index 2e1eb6e0e1..0281f9a315 100644 --- a/library/python/ya.make +++ b/library/python/ya.make @@ -34,7 +34,7 @@ RECURSE( cityhash/test clickhouse_client cmain - codecs + codecs codecs/gen_corpus codecs/test compress @@ -70,8 +70,8 @@ RECURSE( errorboosterclient filelock filelock/ut - filesys - filesys/ut + filesys + filesys/ut find_root flask flask_passport @@ -84,8 +84,8 @@ RECURSE( fs geolocation geolocation/ut - geohash - geohash/ut + geohash + geohash/ut golovan_stats_aggregator granular_settings granular_settings/tests @@ -123,10 +123,10 @@ RECURSE( monlib/examples monlib/so murmurhash - nirvana - nirvana_api - nirvana_api/test_lib - nirvana_test + nirvana + nirvana_api + nirvana_api/test_lib + nirvana_test nstools nyt oauth @@ -137,10 +137,10 @@ RECURSE( par_apply/test path path/tests - protobuf + protobuf pymain pyscopg2 - pytest + pytest pytest-mongodb pytest/allure pytest/empty @@ -156,7 +156,7 @@ RECURSE( resource retry retry/tests - runtime + runtime runtime/main runtime/test runtime_py3 |