diff options
author | Oleg Sidorkin <osidorkin@gmail.com> | 2022-02-10 16:49:36 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:49:36 +0300 |
commit | 5ce74d4fee2d42a4b86efc02dfdc704d458760e1 (patch) | |
tree | f16a3558ca40d453a1c6a2ed764bd75d64cffade /library/cpp/containers | |
parent | cd33f9aa8461f8e2b0b9e68efbb6bc9856197dc9 (diff) | |
download | ydb-5ce74d4fee2d42a4b86efc02dfdc704d458760e1.tar.gz |
Restoring authorship annotation for Oleg Sidorkin <osidorkin@gmail.com>. Commit 1 of 2.
Diffstat (limited to 'library/cpp/containers')
-rw-r--r-- | library/cpp/containers/flat_hash/flat_hash.h | 2 | ||||
-rw-r--r-- | library/cpp/containers/flat_hash/lib/iterator.h | 8 | ||||
-rw-r--r-- | library/cpp/containers/flat_hash/lib/map.h | 22 | ||||
-rw-r--r-- | library/cpp/containers/sorted_vector/sorted_vector.h | 130 | ||||
-rw-r--r-- | library/cpp/containers/sorted_vector/sorted_vector_ut.cpp | 42 | ||||
-rw-r--r-- | library/cpp/containers/sorted_vector/ut/ya.make | 18 | ||||
-rw-r--r-- | library/cpp/containers/sorted_vector/ya.make | 4 |
7 files changed, 113 insertions, 113 deletions
diff --git a/library/cpp/containers/flat_hash/flat_hash.h b/library/cpp/containers/flat_hash/flat_hash.h index 582b8ae8f5..0fad098a59 100644 --- a/library/cpp/containers/flat_hash/flat_hash.h +++ b/library/cpp/containers/flat_hash/flat_hash.h @@ -42,7 +42,7 @@ using TDenseHashSetImpl = namespace NFH { -/* flat_map: Fast and highly customizable hash map. +/* flat_map: Fast and highly customizable hash map. * * Most features would be available soon. * Until that time we strongly insist on using only class aliases listed below. diff --git a/library/cpp/containers/flat_hash/lib/iterator.h b/library/cpp/containers/flat_hash/lib/iterator.h index f6b1e74355..bec518481b 100644 --- a/library/cpp/containers/flat_hash/lib/iterator.h +++ b/library/cpp/containers/flat_hash/lib/iterator.h @@ -65,10 +65,10 @@ public: return &Cont_->Node(Idx_); } - const pointer operator->() const { - return &Cont_->Node(Idx_); - } - + const pointer operator->() const { + return &Cont_->Node(Idx_); + } + bool operator==(const TIterator& rhs) const noexcept { Y_ASSERT(Cont_ == rhs.Cont_); return Idx_ == rhs.Idx_; diff --git a/library/cpp/containers/flat_hash/lib/map.h b/library/cpp/containers/flat_hash/lib/map.h index f77c318a61..42fa0dda35 100644 --- a/library/cpp/containers/flat_hash/lib/map.h +++ b/library/cpp/containers/flat_hash/lib/map.h @@ -4,8 +4,8 @@ #include "concepts/iterator.h" #include <util/generic/algorithm.h> -#include <util/generic/mapfindptr.h> - +#include <util/generic/mapfindptr.h> + namespace NFlatHash { namespace NPrivate { @@ -34,15 +34,15 @@ class TMap : private TTable<Hash, NPrivate::TMapKeyGetter, Probing, SizeFitter, - Expander>, - public TMapOps<TMap<Key, - T, - Hash, - KeyEqual, - Container, - Probing, - SizeFitter, - Expander>> + Expander>, + public TMapOps<TMap<Key, + T, + Hash, + KeyEqual, + Container, + Probing, + SizeFitter, + Expander>> { private: using TBase = TTable<Hash, diff --git a/library/cpp/containers/sorted_vector/sorted_vector.h b/library/cpp/containers/sorted_vector/sorted_vector.h index 123539af9e..7a7550034e 100644 --- a/library/cpp/containers/sorted_vector/sorted_vector.h +++ b/library/cpp/containers/sorted_vector/sorted_vector.h @@ -12,35 +12,35 @@ namespace NSorted { namespace NPrivate { - template <class TPredicate> + template <class TPredicate> struct TEqual { - template<typename TValueType1, typename TValueType2> - inline bool operator()(const TValueType1& l, const TValueType2& r) const { + template<typename TValueType1, typename TValueType2> + inline bool operator()(const TValueType1& l, const TValueType2& r) const { TPredicate comp; return comp(l, r) == comp(r, l); } }; - template <typename TValueType, class TPredicate, class TKeyExtractor> + template <typename TValueType, class TPredicate, class TKeyExtractor> struct TKeyCompare { inline bool operator()(const TValueType& l, const TValueType& r) const { TKeyExtractor extractKey; return TPredicate()(extractKey(l), extractKey(r)); } - template<typename TKeyType> + template<typename TKeyType> inline bool operator()(const TKeyType& l, const TValueType& r) const { return TPredicate()(l, TKeyExtractor()(r)); } - template<typename TKeyType> + template<typename TKeyType> inline bool operator()(const TValueType& l, const TKeyType& r) const { return TPredicate()(TKeyExtractor()(l), r); } }; template <typename TValueType, class TPredicate> - struct TKeyCompare<TValueType, TPredicate, TIdentity> { - template <typename TValueType1, typename TValueType2> - inline bool operator()(const TValueType1& l, const TValueType2& r) const { + struct TKeyCompare<TValueType, TPredicate, TIdentity> { + template <typename TValueType1, typename TValueType2> + inline bool operator()(const TValueType1& l, const TValueType2& r) const { return TPredicate()(l, r); } }; @@ -53,9 +53,9 @@ namespace NSorted { class TSortedVector: public TVector<TValueType, A> { private: typedef TVector<TValueType, A> TBase; - typedef NPrivate::TKeyCompare<TValueType, TPredicate, TKeyExtractor> TKeyCompare; - typedef NPrivate::TEqual<TKeyCompare> TValueEqual; - typedef NPrivate::TEqual<TPredicate> TKeyEqual; + typedef NPrivate::TKeyCompare<TValueType, TPredicate, TKeyExtractor> TKeyCompare; + typedef NPrivate::TEqual<TKeyCompare> TValueEqual; + typedef NPrivate::TEqual<TPredicate> TKeyEqual; public: typedef TValueType value_type; @@ -197,8 +197,8 @@ namespace NSorted { this->MakeUnique(); } - template<class K> - inline const_iterator Find(const K& key) const { + template<class K> + inline const_iterator Find(const K& key) const { const_iterator i = LowerBound(key); if (i == TBase::end() || !TKeyEqual()(TKeyExtractor()(*i), key)) return TBase::end(); @@ -207,13 +207,13 @@ namespace NSorted { } // STL-compatible synonym - template<class K> - Y_FORCE_INLINE const_iterator find(const K& key) const { + template<class K> + Y_FORCE_INLINE const_iterator find(const K& key) const { return this->Find(key); } - template<class K> - inline iterator Find(const K& key) { + template<class K> + inline iterator Find(const K& key) { iterator i = LowerBound(key); if (i == TBase::end() || !TKeyEqual()(TKeyExtractor()(*i), key)) return TBase::end(); @@ -222,89 +222,89 @@ namespace NSorted { } // STL-compatible synonym - template<class K> - Y_FORCE_INLINE iterator find(const K& key) { + template<class K> + Y_FORCE_INLINE iterator find(const K& key) { return this->Find(key); } - template<class K> - Y_FORCE_INLINE bool Has(const K& key) const { + template<class K> + Y_FORCE_INLINE bool Has(const K& key) const { return this->find(key) != TBase::end(); } - template<class K> - Y_FORCE_INLINE bool has(const K& key) const { + template<class K> + Y_FORCE_INLINE bool has(const K& key) const { return this->Has(key); } - template<class K> - Y_FORCE_INLINE iterator LowerBound(const K& key) { + template<class K> + Y_FORCE_INLINE iterator LowerBound(const K& key) { return ::LowerBound(TBase::begin(), TBase::end(), key, TKeyCompare()); } // STL-compatible synonym - template<class K> - Y_FORCE_INLINE iterator lower_bound(const K& key) { + template<class K> + Y_FORCE_INLINE iterator lower_bound(const K& key) { return this->LowerBound(key); } - template<class K> - Y_FORCE_INLINE const_iterator LowerBound(const K& key) const { + template<class K> + Y_FORCE_INLINE const_iterator LowerBound(const K& key) const { return ::LowerBound(TBase::begin(), TBase::end(), key, TKeyCompare()); } // STL-compatible synonym - template<class K> - Y_FORCE_INLINE const_iterator lower_bound(const K& key) const { + template<class K> + Y_FORCE_INLINE const_iterator lower_bound(const K& key) const { return this->LowerBound(key); } - template<class K> - Y_FORCE_INLINE iterator UpperBound(const K& key) { + template<class K> + Y_FORCE_INLINE iterator UpperBound(const K& key) { return ::UpperBound(TBase::begin(), TBase::end(), key, TKeyCompare()); } // STL-compatible synonym - template<class K> - Y_FORCE_INLINE iterator upper_bound(const K& key) { + template<class K> + Y_FORCE_INLINE iterator upper_bound(const K& key) { return this->UpperBound(key); } - template<class K> - Y_FORCE_INLINE const_iterator UpperBound(const K& key) const { + template<class K> + Y_FORCE_INLINE const_iterator UpperBound(const K& key) const { return ::UpperBound(TBase::begin(), TBase::end(), key, TKeyCompare()); } // STL-compatible synonym - template<class K> - Y_FORCE_INLINE const_iterator upper_bound(const K& key) const { + template<class K> + Y_FORCE_INLINE const_iterator upper_bound(const K& key) const { return this->UpperBound(key); } - template<class K> - Y_FORCE_INLINE std::pair<iterator, iterator> EqualRange(const K& key) { + template<class K> + Y_FORCE_INLINE std::pair<iterator, iterator> EqualRange(const K& key) { return std::equal_range(TBase::begin(), TBase::end(), key, TKeyCompare()); } // STL-compatible synonym - template<class K> - Y_FORCE_INLINE std::pair<iterator, iterator> equal_range(const K& key) { + template<class K> + Y_FORCE_INLINE std::pair<iterator, iterator> equal_range(const K& key) { return this->EqualRange(key); } - template<class K> - Y_FORCE_INLINE std::pair<const_iterator, const_iterator> EqualRange(const K& key) const { + template<class K> + Y_FORCE_INLINE std::pair<const_iterator, const_iterator> EqualRange(const K& key) const { return std::equal_range(TBase::begin(), TBase::end(), key, TKeyCompare()); } // STL-compatible synonym - template<class K> - Y_FORCE_INLINE std::pair<const_iterator, const_iterator> equal_range(const K& key) const { + template<class K> + Y_FORCE_INLINE std::pair<const_iterator, const_iterator> equal_range(const K& key) const { return this->EqualRange(key); } - template<class K> - inline void Erase(const K& key) { + template<class K> + inline void Erase(const K& key) { std::pair<iterator, iterator> res = EqualRange(key); TBase::erase(res.first, res.second); } @@ -314,8 +314,8 @@ namespace NSorted { this->Erase(key); } - template<class K> - inline size_t count(const K& key) const { + template<class K> + inline size_t count(const K& key) const { const std::pair<const_iterator, const_iterator> range = this->EqualRange(key); return std::distance(range.first, range.second); } @@ -369,19 +369,19 @@ namespace NSorted { return i->second; } - template<class K> - inline const TValueType& Get(const K& key, const TValueType& def) const { + template<class K> + inline const TValueType& Get(const K& key, const TValueType& def) const { typename TBase::const_iterator i = TBase::Find(key); return i != TBase::end() ? i->second : def; } - template<class K> - Y_FORCE_INLINE TValueType& operator[](const K& key) { + template<class K> + Y_FORCE_INLINE TValueType& operator[](const K& key) { return Get(key); } - template<class K> - const TValueType& at(const K& key) const { + template<class K> + const TValueType& at(const K& key) const { const auto i = TBase::Find(key); if (i == TBase::end()) { throw std::out_of_range("NSorted::TSimpleMap: missing key"); @@ -390,8 +390,8 @@ namespace NSorted { return i->second; } - template<class K> - TValueType& at(const K& key) { + template<class K> + TValueType& at(const K& key) { return const_cast<TValueType&>( const_cast<const TSimpleMap<TKeyType, TValueType, TPredicate, A>*>(this)->at(key)); } @@ -412,7 +412,7 @@ namespace NSorted { typedef typename TBase::iterator iterator; typedef typename TBase::const_iterator const_iterator; typedef typename TBase::size_type size_type; - typedef NPrivate::TEqual<TPredicate> TKeyEqual; + typedef NPrivate::TEqual<TPredicate> TKeyEqual; public: inline TSimpleSet() @@ -441,14 +441,14 @@ namespace NSorted { return *i; } - template<class K> - inline const TValueType& Get(const K& key, const TValueType& def) const { + template<class K> + inline const TValueType& Get(const K& key, const TValueType& def) const { typename TBase::const_iterator i = TBase::Find(key); return i != TBase::end() ? *i : def; } - template<class K> - Y_FORCE_INLINE TValueType& operator[](const K& key) { + template<class K> + Y_FORCE_INLINE TValueType& operator[](const K& key) { return Get(key); } diff --git a/library/cpp/containers/sorted_vector/sorted_vector_ut.cpp b/library/cpp/containers/sorted_vector/sorted_vector_ut.cpp index 893862f098..4eaa28bc16 100644 --- a/library/cpp/containers/sorted_vector/sorted_vector_ut.cpp +++ b/library/cpp/containers/sorted_vector/sorted_vector_ut.cpp @@ -1,24 +1,24 @@ -#include "sorted_vector.h" - +#include "sorted_vector.h" + #include <library/cpp/testing/unittest/registar.h> - -#include <util/generic/string.h> -#include <util/generic/strbuf.h> - -Y_UNIT_TEST_SUITE(TestSimpleMap) { - - Y_UNIT_TEST(TestFindPrt) { - NSorted::TSimpleMap<TString, TString> map( - {std::make_pair(TString("a"), TString("a")), std::make_pair(TString("b"), TString("b"))}); - - UNIT_ASSERT_VALUES_UNEQUAL(map.FindPtr(TString("a")), nullptr); - UNIT_ASSERT_VALUES_EQUAL(map.FindPtr(TString("c")), nullptr); - + +#include <util/generic/string.h> +#include <util/generic/strbuf.h> + +Y_UNIT_TEST_SUITE(TestSimpleMap) { + + Y_UNIT_TEST(TestFindPrt) { + NSorted::TSimpleMap<TString, TString> map( + {std::make_pair(TString("a"), TString("a")), std::make_pair(TString("b"), TString("b"))}); + + UNIT_ASSERT_VALUES_UNEQUAL(map.FindPtr(TString("a")), nullptr); + UNIT_ASSERT_VALUES_EQUAL(map.FindPtr(TString("c")), nullptr); + UNIT_ASSERT_VALUES_UNEQUAL(map.FindPtr(TStringBuf("a")), nullptr); UNIT_ASSERT_VALUES_EQUAL(map.FindPtr(TStringBuf("c")), nullptr); - - UNIT_ASSERT_VALUES_UNEQUAL(map.FindPtr("a"), nullptr); - UNIT_ASSERT_VALUES_EQUAL(map.FindPtr("c"), nullptr); - } - -} + + UNIT_ASSERT_VALUES_UNEQUAL(map.FindPtr("a"), nullptr); + UNIT_ASSERT_VALUES_EQUAL(map.FindPtr("c"), nullptr); + } + +} diff --git a/library/cpp/containers/sorted_vector/ut/ya.make b/library/cpp/containers/sorted_vector/ut/ya.make index eb8a5b4bef..f509db58c5 100644 --- a/library/cpp/containers/sorted_vector/ut/ya.make +++ b/library/cpp/containers/sorted_vector/ut/ya.make @@ -1,10 +1,10 @@ UNITTEST_FOR(library/cpp/containers/sorted_vector) - -OWNER(udovichenko-r) - - -SRCS( - sorted_vector_ut.cpp -) - -END() + +OWNER(udovichenko-r) + + +SRCS( + sorted_vector_ut.cpp +) + +END() diff --git a/library/cpp/containers/sorted_vector/ya.make b/library/cpp/containers/sorted_vector/ya.make index 1975c5dc90..e8923b1db2 100644 --- a/library/cpp/containers/sorted_vector/ya.make +++ b/library/cpp/containers/sorted_vector/ya.make @@ -7,5 +7,5 @@ SRCS( ) END() - -RECURSE_FOR_TESTS(ut) + +RECURSE_FOR_TESTS(ut) |