MCPcopy Create free account
hub / github.com/catboost/catboost / TLRUCache

Class TLRUCache

library/cpp/cache/cache.h:712–736  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

710
711template <typename TKey, typename TValue, typename TDeleter = TNoopDelete, class TSizeProvider = TUniformSizeProvider<TValue>, typename TAllocator = std::allocator<typename TLRUList<TKey, TValue, TSizeProvider>::TItem>>
712class TLRUCache: public TCache<TKey, TValue, TLRUList<TKey, TValue, TSizeProvider>, TDeleter, TAllocator> {
713 using TListType = TLRUList<TKey, TValue, TSizeProvider>;
714 typedef TCache<TKey, TValue, TListType, TDeleter, TAllocator> TBase;
715
716public:
717 TLRUCache(size_t maxSize, bool multiValue = false, const TSizeProvider& sizeProvider = TSizeProvider())
718 : TBase(TListType(maxSize, sizeProvider), multiValue)
719 {
720 }
721
722public:
723 typedef typename TBase::TIterator TIterator;
724
725 TValue& GetOldest() {
726 return TBase::List.GetOldest()->Value;
727 }
728
729 TIterator FindOldest() {
730 return TBase::Empty() ? TBase::End() : this->FindByItem(TBase::List.GetOldest());
731 }
732
733 size_t TotalSize() const {
734 return TBase::List.GetTotalSize();
735 }
736};
737
738template <typename TKey, typename TValue, typename TDeleter = TNoopDelete, typename TAllocator = std::allocator<TKey>, class TSizeProvider = TUniformSizeProvider<TValue>>
739class TLFUCache: public TCache<TKey, TValue, TLFUList<TKey, TValue, TSizeProvider>, TDeleter, TAllocator> {

Callers

nothing calls this directly

Calls 1

GetOldestMethod · 0.80

Tested by

no test coverage detected