4#ifndef _Stroika_Foundation_Cache_LRUCache_h_
5#define _Stroika_Foundation_Cache_LRUCache_h_ 1
7#include "Stroika/Foundation/StroikaPreComp.h"
14#include "Stroika/Foundation/Common/Common.h"
15#include "Stroika/Foundation/Common/Concepts.h"
17#include "Stroika/Foundation/Containers/Mapping.h"
93 template <
typename KEY,
typename VALUE,
typename KEY_EQUALS_COMPARER = equal_to<KEY>,
typename KEY_HASH_FUNCTION =
nullptr_t,
typename STATS_TYPE = Statistics::StatsType_DEFAULT>
99 using KeyEqualsCompareFunctionType = KEY_EQUALS_COMPARER;
154 nonvirtual
size_t GetMaxCacheSize ()
const;
165 nonvirtual KeyEqualsCompareFunctionType GetKeyEqualsCompareFunction ()
const;
175 nonvirtual
size_t GetHashTableSize ()
const;
186 nonvirtual
void clear ();
261 [[
deprecated (
"Since Stroika v3.0d5 use Cache::Factory::LRUCache_WithHash or NoHash")]]
LRUCache (
267 [[
deprecated (
"Since Stroika v3.0d5 use Cache::Factory::LRUCache_WithHash or NoHash")]]
LRUCache (
274 const size_t fHashtableSize_{1};
277 struct KeyValuePair_ {
294 struct CacheElement_;
295 struct CacheIterator_;
297 nonvirtual CacheIterator_ begin_ ()
const;
298 nonvirtual CacheIterator_ end_ ()
const;
300 nonvirtual
void ClearCache_ ();
320 nonvirtual
void ShuffleToHead_ (
size_t chainIdx, CacheElement_*
b);
340 template <
typename KEY,
typename VALUE,
typename STATS_TYPE = Statistics::StatsType_DEFAULT>
342 template <Common::IEqualsComparer<KEY> KEY_EQUALS_COMPARER = equal_to<KEY>>
359 template <
typename KEY,
typename VALUE,
typename STATS_TYPE = Statistics::StatsType_DEFAULT,
typename DEFAULT_KEY_EQUALS_COMPARER = equal_to<KEY>>
361 template <
typename KEY_HASH_FUNCTION = hash<KEY>>
368 template <
typename KEY_EQUALS_COMPARER,
typename KEY_HASH_FUNCTION = hash<KEY>>
386#include "LRUCache.inl"
LRUCache implements a simple least-recently-used caching strategy, with optional hashing (of keys) to...
nonvirtual Containers::Mapping< KEY, VALUE > Elements() const
nonvirtual void Add(typename Common::ArgByValueType< KEY > key, typename Common::ArgByValueType< VALUE > value)
nonvirtual void SetMaxCacheSize(size_t maxCacheSize)
nonvirtual VALUE LookupValue(typename Common::ArgByValueType< KEY > key, const function< VALUE(typename Common::ArgByValueType< KEY >)> &valueFetcher)
nonvirtual optional< VALUE > Lookup(typename Common::ArgByValueType< KEY > key)
NOT a real mutex - just a debugging infrastructure support tool so in debug builds can be assured thr...
Logically halfway between std::array and std::vector; Smart 'direct memory array' - which when needed...
conditional_t<(sizeof(CHECK_T)<=2 *sizeof(void *)) and is_trivially_copyable_v< CHECK_T >, CHECK_T, const CHECK_T & > ArgByValueType
This is an alias for 'T' - but how we want to pass it on stack as formal parameter.