226 using TraitsType = TRAITS;
231 using KeyType =
typename TRAITS::KeyType;
236 using ValueType =
typename TRAITS::ValueType;
241 using KeyEqualsCompareFunctionType =
typename TRAITS::KeyEqualsCompareFunctionType;
246 using KeyHashFunctionType =
typename TRAITS::KeyHashFunctionType;
251 using StatsType =
typename TRAITS::StatsType;
279 requires (same_as<typename TRAITS::KeyHashFunctionType, nullptr_t> and
280 same_as<typename TRAITS::KeyEqualsCompareFunctionType, equal_to<KEY>>);
281 LRUCache (
size_t maxCacheSize,
const typename TRAITS::KeyEqualsCompareFunctionType& keyEqualsComparer = {})
282 requires (same_as<typename TRAITS::KeyHashFunctionType, nullptr_t>);
283 LRUCache (
size_t maxCacheSize,
const typename TRAITS::KeyEqualsCompareFunctionType& keyEqualsComparer = {},
size_t hashTableSize = 1,
284 const typename TRAITS::KeyHashFunctionType& hashFunction =
typename TRAITS::KeyHashFunctionType{})
285 requires (not same_as<typename TRAITS::KeyHashFunctionType, nullptr_t>);
286 LRUCache (
size_t maxCacheSize,
size_t hashTableSize,
287 const typename TRAITS::KeyHashFunctionType& hashFunction =
typename TRAITS::KeyHashFunctionType{})
288 requires (not same_as<typename TRAITS::KeyHashFunctionType, nullptr_t>);
292 requires (same_as<typename TRAITS::KeyHashFunctionType, nullptr_t>);
294 requires (not same_as<typename TRAITS::KeyHashFunctionType, nullptr_t>);
305 nonvirtual
size_t GetMaxCacheSize ()
const;
311 nonvirtual
void SetMaxCacheSize (
size_t maxCacheSize);
316 nonvirtual KeyEqualsCompareFunctionType GetKeyEqualsCompareFunction ()
const;
321 nonvirtual StatsType GetStats ()
const;
326 nonvirtual
size_t GetHashTableSize ()
const;
331 nonvirtual KeyHashFunctionType GetKeyHashFunction ()
const;
339 nonvirtual
void clear ();
347 template <qCompilerAndStdLib_Constra
intDiffersInTemplateRedeclaration_BWA (predicate<KEY>) PREDICATE>
348 nonvirtual
void RemoveAll (PREDICATE&& removeIfReturnsTrue);
358 template <
typename V = VALUE>
359 requires (not IValuelessCache<V>)
361 template <
typename V = VALUE>
362 requires (IValuelessCache<V>)
411 template <
typename V = VALUE>
412 requires (not IValuelessCache<V>)
414 template <
typename V = VALUE>
415 requires (IValuelessCache<V>)
433 [[deprecated (
"Since Stroika v3.0d5 use Cache::Factory::LRUCache_WithHash or NoHash")]]
LRUCache (
434 pair<KEY, VALUE> ignored,
size_t maxCacheSize = 1,
const typename TRAITS::KeyEqualsCompareFunctionType& keyEqualsComparer = {},
435 size_t hashTableSize = 1,
const typename TRAITS::KeyHashFunctionType& hashFunction =
typename TRAITS::KeyHashFunctionType{})
436 : LRUCache{maxCacheSize, keyEqualsComparer, hashTableSize, hashFunction}
439 [[deprecated (
"Since Stroika v3.0d5 use Cache::Factory::LRUCache_WithHash or NoHash")]] LRUCache (
440 pair<KEY, VALUE> ignored,
size_t maxCacheSize,
size_t hashTableSize,
441 const typename TRAITS::KeyHashFunctionType& hashFunction = hash<KEY>{})
442 : LRUCache{maxCacheSize, hashTableSize, hashFunction}
447 const size_t fHashtableSize_{1};
450 struct KeyValuePair_ {
457 nonvirtual
size_t H_ (
typename Common::ArgByValueType<KEY> k)
const;
461 using MaybeMutexType_ =
462 conditional_t<TRAITS::kInternallySynchronized == Execution::InternallySynchronized::eInternallySynchronized, shared_timed_mutex, Debug::AssertExternallySynchronizedMutex>;
470 struct CacheElement_;
471 struct CacheIterator_;
473 nonvirtual CacheIterator_ begin_ ()
const;
474 nonvirtual CacheIterator_ end_ ()
const;
476 nonvirtual
void ClearCache_ ();
484 nonvirtual optional<KeyValuePair_>* AddNewButDontFillIn_ (
typename Common::ArgByValueType<KeyType> item);
492 nonvirtual optional<KeyValuePair_>* LookupElement_ (
typename Common::ArgByValueType<KeyType> item);
496 nonvirtual
void ShuffleToHead_ (
size_t chainIdx, CacheElement_* b);
498 static constexpr size_t kPreallocatedHashtableSize_ =
499 same_as<typename TRAITS::KeyHashFunctionType, nullptr_t> ? 1 : 5;
500 Memory::InlineBuffer<vector<CacheElement_>, kPreallocatedHashtableSize_> fCachedElts_BUF_{};
501 Memory::InlineBuffer<CacheElement_*, kPreallocatedHashtableSize_> fCachedElts_First_{};
502 Memory::InlineBuffer<CacheElement_*, kPreallocatedHashtableSize_> fCachedElts_Last_{};
547#if __cplusplus >= kStrokia_Foundation_Common_cplusplus_23 || _HAS_CXX23
548 template <Common::IEqualsComparer<KEY> KEY_EQUALS_COMPARER = equal_to<KEY>>
549 static auto operator() (
size_t maxCacheSize = 1, KEY_EQUALS_COMPARER&& keyComparer = {});
551 template <Common::IEqualsComparer<KEY> KEY_EQUALS_COMPARER = equal_to<KEY>>
552 auto operator() (
size_t maxCacheSize = 1, KEY_EQUALS_COMPARER&& keyComparer = {})
const;
558 template <
typename KEY_HASH_FUNCTION = hash<KEY>>
559#if __cplusplus >= kStrokia_Foundation_Common_cplusplus_23 || _HAS_CXX23
560 static auto operator() (
size_t maxCacheSize,
size_t hashTableSize, KEY_HASH_FUNCTION&& hashFunction = {});
562 auto operator() (
size_t maxCacheSize,
size_t hashTableSize, KEY_HASH_FUNCTION&& hashFunction = {})
const;
564 template <
typename KEY_EQUALS_COMPARER = equal_to<KEY>,
typename KEY_HASH_FUNCTION = hash<KEY>>
565#if __cplusplus >= kStrokia_Foundation_Common_cplusplus_23 || _HAS_CXX23
566 static auto operator() (
size_t maxCacheSize, KEY_EQUALS_COMPARER&& keyComparer,
size_t hashTableSize,
567 KEY_HASH_FUNCTION&& hashFunction = {});
569 auto operator() (
size_t maxCacheSize, KEY_EQUALS_COMPARER&& keyComparer,
size_t hashTableSize, KEY_HASH_FUNCTION&& hashFunction = {})
const;