diff options
author | Vlad Yaroslavlev <vladon@vladon.com> | 2022-02-10 16:46:23 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:46:23 +0300 |
commit | 706b83ed7de5a473436620367af31fc0ceecde07 (patch) | |
tree | 103305d30dec77e8f6367753367f59b3cd68f9f1 /library/cpp/cache | |
parent | 918e8a1574070d0ec733f0b76cfad8f8892ad2e5 (diff) | |
download | ydb-706b83ed7de5a473436620367af31fc0ceecde07.tar.gz |
Restoring authorship annotation for Vlad Yaroslavlev <vladon@vladon.com>. Commit 1 of 2.
Diffstat (limited to 'library/cpp/cache')
-rw-r--r-- | library/cpp/cache/cache.h | 30 | ||||
-rw-r--r-- | library/cpp/cache/ut/cache_ut.cpp | 10 |
2 files changed, 20 insertions, 20 deletions
diff --git a/library/cpp/cache/cache.h b/library/cpp/cache/cache.h index 6dc997076d..f79be81fa5 100644 --- a/library/cpp/cache/cache.h +++ b/library/cpp/cache/cache.h @@ -81,7 +81,7 @@ public: } TItem* GetOldest() { - typename TListType::TIterator it = List.Begin(); + typename TListType::TIterator it = List.Begin(); Y_ASSERT(it != List.End()); return &*it; } @@ -116,8 +116,8 @@ public: } private: - typedef TIntrusiveList<TItem> TListType; - TListType List; + typedef TIntrusiveList<TItem> TListType; + TListType List; TSizeProvider SizeProvider; size_t ItemsAmount; size_t TotalSize; @@ -189,7 +189,7 @@ public: } TItem* GetLeastFrequentlyUsed() { - typename TListType::TIterator it = List.Begin(); + typename TListType::TIterator it = List.Begin(); Y_ASSERT(it != List.End()); return &*it; } @@ -201,7 +201,7 @@ public: void Promote(TItem* item) { size_t counter = ++item->Counter; - typename TListType::TIterator it = item; + typename TListType::TIterator it = item; while (it != List.End() && counter >= it->Counter) { ++it; } @@ -223,8 +223,8 @@ public: } private: - typedef TIntrusiveList<TItem> TListType; - TListType List; + typedef TIntrusiveList<TItem> TListType; + TListType List; size_t ListSize; size_t MaxSize; }; @@ -366,18 +366,18 @@ private: } private: - TVector<TItem*> Heap; - THashSet<TItem*> Removed; + TVector<TItem*> Heap; + THashSet<TItem*> Removed; size_t Size; size_t MaxSize; }; -template <typename TKey, typename TValue, typename TListType, typename TDeleter> +template <typename TKey, typename TValue, typename TListType, typename TDeleter> class TCache { - typedef typename TListType::TItem TItem; + typedef typename TListType::TItem TItem; typedef typename TItem::THash THash; - typedef THashMultiSet<TItem, THash> TIndex; + typedef THashMultiSet<TItem, THash> TIndex; typedef typename TIndex::iterator TIndexIterator; typedef typename TIndex::const_iterator TIndexConstIterator; @@ -418,7 +418,7 @@ public: return Iter->Value; } - friend class TCache<TKey, TValue, TListType, TDeleter>; + friend class TCache<TKey, TValue, TListType, TDeleter>; private: TIndexConstIterator Iter; @@ -547,7 +547,7 @@ public: protected: TIndex Index; - TListType List; + TListType List; bool MultiValue; TIterator FindByItem(TItem* item) { @@ -570,7 +570,7 @@ protected: struct TNoopDelete { template <class T> - static inline void Destroy(const T&) noexcept { + static inline void Destroy(const T&) noexcept { } }; diff --git a/library/cpp/cache/ut/cache_ut.cpp b/library/cpp/cache/ut/cache_ut.cpp index 329872cfde..33dacbc565 100644 --- a/library/cpp/cache/ut/cache_ut.cpp +++ b/library/cpp/cache/ut/cache_ut.cpp @@ -3,7 +3,7 @@ #include <library/cpp/testing/unittest/registar.h> struct TStrokaWeighter { - static size_t Weight(const TString& s) { + static size_t Weight(const TString& s) { return s.size(); } }; @@ -115,7 +115,7 @@ Y_UNIT_TEST_SUITE(TCacheTest) { } Y_UNIT_TEST(SimpleTest) { - typedef TLRUCache<int, TString> TCache; + typedef TLRUCache<int, TString> TCache; TCache s(2); // size 2 s.Insert(1, "abcd"); UNIT_ASSERT(s.Find(1) != s.End()); @@ -312,7 +312,7 @@ Y_UNIT_TEST_SUITE(TCacheTest) { } Y_UNIT_TEST(MultiCacheTest) { - typedef TLRUCache<int, TString> TCache; + typedef TLRUCache<int, TString> TCache; TCache s(3, true); UNIT_ASSERT(s.Insert(1, "abcd")); UNIT_ASSERT(s.Insert(1, "bcde")); @@ -358,7 +358,7 @@ Y_UNIT_TEST_SUITE(TCacheTest) { } Y_UNIT_TEST_SUITE(TThreadSafeCacheTest) { - typedef TThreadSafeCache<ui32, TString, ui32> TCache; + typedef TThreadSafeCache<ui32, TString, ui32> TCache; const char* VALS[] = {"abcd", "defg", "hjkl"}; @@ -369,7 +369,7 @@ Y_UNIT_TEST_SUITE(TThreadSafeCacheTest) { } TValue* CreateObject(ui32 i) const override { Creations++; - return new TString(VALS[i]); + return new TString(VALS[i]); } mutable i32 Creations = 0; |