engine
 
载入中...
搜索中...
未找到
类 | Public 成员函数 | Protected 成员函数 | 所有成员列表
TLruCache< KeyType, ValueType, KeyComp > 模板类 参考

Implements a Least Recently Used (LRU) cache. 更多...

#include <LruCache.h>

类

class  TBaseIterator
 Base class for cache iterators. 更多...
 
class  TConstIterator
 Cache iterator (const). 更多...
 
class  TIterator
 Cache iterator. 更多...
 

Public 成员函数

void Add (const KeyType &Key, const ValueType &Value)
 Add an entry to the cache. 更多...
 
FORCEINLINE bool Contains (const KeyType &Key) const
 Check whether an entry with the specified key is in the cache. 更多...
 
template<typename Predicate >
FORCEINLINE bool ContainsByPredicate (Predicate Pred) const
 Check whether an entry for which a predicate returns true is in the cache. 更多...
 
void Empty (int32 InMaxNumElements=0)
 Empty the cache. 更多...
 
template<typename Predicate >
TArray< ValueType > FilterByPredicate (Predicate Pred) const
 Filter the entries in the cache using a predicate. 更多...
 
FORCEINLINE const ValueType * Find (const KeyType &Key) const
 Find the value of the entry with the specified key. 更多...
 
const ValueType * FindAndTouch (const KeyType &Key)
 Find the value of the entry with the specified key and mark it as the most recently used. 更多...
 
const ValueType & FindAndTouchChecked (const KeyType &Key)
 Find the value of the entry with the specified key and mark it as the most recently used. 更多...
 
ValueType FindAndTouchRef (const KeyType &Key)
 Find the value of the entry with the specified key and mark it as the most recently used. 更多...
 
template<typename Predicate >
const ValueType * FindByPredicate (Predicate Pred) const
 Find the value of an entry using a predicate. 更多...
 
FORCEINLINE const ValueType & FindChecked (const KeyType &Key) const
 Find the value of the entry with the specified key. 更多...
 
FORCEINLINE ValueType FindRef (const KeyType &Key) const
 Find the value of the entry with the specified key. 更多...
 
void GetKeys (TArray< KeyType > &OutKeys) const
 Find the keys of all cached entries. 更多...
 
FORCEINLINE int32 Max () const
 Get the maximum number of entries in the cache. 更多...
 
FORCEINLINE int32 Num () const
 Get the number of entries in the cache. 更多...
 
void Remove (const KeyType &Key)
 Remove all entries with the specified key from the cache. 更多...
 
template<typename Predicate >
int32 RemoveByPredicate (Predicate Pred)
 Remove all entries using a predicate. 更多...
 
FORCEINLINE ValueType RemoveLeastRecent ()
 Remove and return the least recent element from the cache. 更多...
 
 TLruCache ()
 Default constructor (empty cache that cannot hold any values).
 
 TLruCache (int32 InMaxNumElements)
 Create and initialize a new instance. 更多...
 
 ~TLruCache ()
 Destructor.
 

Protected 成员函数

FORCEINLINE void MarkAsRecent (FCacheEntry &Entry)
 Mark the given entry as recently used. 更多...
 
FORCEINLINE void Remove (FCacheEntry *Entry)
 Remove the specified entry from the cache. 更多...
 

详细描述

template<typename KeyType, typename ValueType, typename KeyComp = DefaultKeyComparer<KeyType>>
class TLruCache< KeyType, ValueType, KeyComp >

Implements a Least Recently Used (LRU) cache.

参数
KeyTypeThe type of cache entry keys.
ValueTypeThe type of cache entry values.
KeyFuncsOptional functions for comparing keys in the lookup set (see BaseKeyFuncs in Set.h).

构造及析构函数说明

◆ TLruCache()

template<typename KeyType , typename ValueType , typename KeyComp = DefaultKeyComparer<KeyType>>
TLruCache< KeyType, ValueType, KeyComp >::TLruCache ( int32  InMaxNumElements)
inline

Create and initialize a new instance.

参数
InMaxNumElementsThe maximum number of elements this cache can hold.

成员函数说明

◆ Add()

template<typename KeyType , typename ValueType , typename KeyComp = DefaultKeyComparer<KeyType>>
void TLruCache< KeyType, ValueType, KeyComp >::Add ( const KeyType &  Key,
const ValueType &  Value 
)
inline

Add an entry to the cache.

If an entry with the specified key already exists in the cache, the value of the existing entry will be updated. The added or updated entry will be marked as the most recently used one.

参数
KeyThe entry's lookup key.
ValueThe entry's value.
参见
Empty, Find, GetKeys, Remove

◆ Contains()

template<typename KeyType , typename ValueType , typename KeyComp = DefaultKeyComparer<KeyType>>
FORCEINLINE bool TLruCache< KeyType, ValueType, KeyComp >::Contains ( const KeyType &  Key) const
inline

Check whether an entry with the specified key is in the cache.

参数
KeyThe key of the entry to check.
返回
true if the entry is in the cache, false otherwise.
参见
Add, ContainsByPredicate, Empty, FilterByPredicate, Find, GetKeys, Remove

◆ ContainsByPredicate()

template<typename KeyType , typename ValueType , typename KeyComp = DefaultKeyComparer<KeyType>>
template<typename Predicate >
FORCEINLINE bool TLruCache< KeyType, ValueType, KeyComp >::ContainsByPredicate ( Predicate  Pred) const
inline

Check whether an entry for which a predicate returns true is in the cache.

参数
PredThe predicate functor to apply to each entry.
返回
true if at least one matching entry is in the cache, false otherwise.
参见
Contains, FilterByPredicate, FindByPredicate, RemoveByPredicate

◆ Empty()

template<typename KeyType , typename ValueType , typename KeyComp = DefaultKeyComparer<KeyType>>
void TLruCache< KeyType, ValueType, KeyComp >::Empty ( int32  InMaxNumElements = 0)
inline

Empty the cache.

参数
InMaxNumElementsThe maximum number of elements this cache can hold (default = 0).
参见
Add, Find, GetKeys, Max, Num, Remove

◆ FilterByPredicate()

template<typename KeyType , typename ValueType , typename KeyComp = DefaultKeyComparer<KeyType>>
template<typename Predicate >
TArray< ValueType > TLruCache< KeyType, ValueType, KeyComp >::FilterByPredicate ( Predicate  Pred) const
inline

Filter the entries in the cache using a predicate.

参数
PredThe predicate functor to apply to each entry.
返回
Collection of values for which the predicate returned true.
参见
ContainsByPredicate, FindByPredicate, Find, RemoveByPredicate

◆ Find()

template<typename KeyType , typename ValueType , typename KeyComp = DefaultKeyComparer<KeyType>>
FORCEINLINE const ValueType * TLruCache< KeyType, ValueType, KeyComp >::Find ( const KeyType &  Key) const
inline

Find the value of the entry with the specified key.

参数
KeyThe key of the entry to get.
返回
Pointer to the value, or nullptr if not found.
参见
Add, Contains, Empty, FindAndTouch, GetKeys, Remove

◆ FindAndTouch()

template<typename KeyType , typename ValueType , typename KeyComp = DefaultKeyComparer<KeyType>>
const ValueType * TLruCache< KeyType, ValueType, KeyComp >::FindAndTouch ( const KeyType &  Key)
inline

Find the value of the entry with the specified key and mark it as the most recently used.

参数
KeyThe key of the entry to get.
返回
Pointer to the value, or nullptr if not found.
参见
Add, Contains, Empty, Find, GetKeys, Remove

◆ FindAndTouchChecked()

template<typename KeyType , typename ValueType , typename KeyComp = DefaultKeyComparer<KeyType>>
const ValueType & TLruCache< KeyType, ValueType, KeyComp >::FindAndTouchChecked ( const KeyType &  Key)
inline

Find the value of the entry with the specified key and mark it as the most recently used.

参数
KeyThe key of the entry to get.
返回
Pointer to the value, or triggers an assertion if the key does not exist.

◆ FindAndTouchRef()

template<typename KeyType , typename ValueType , typename KeyComp = DefaultKeyComparer<KeyType>>
ValueType TLruCache< KeyType, ValueType, KeyComp >::FindAndTouchRef ( const KeyType &  Key)
inline

Find the value of the entry with the specified key and mark it as the most recently used.

参数
KeyThe key of the entry to get.
返回
Copy of the value, or the default value for the ValueType if the key does not exist.

◆ FindByPredicate()

template<typename KeyType , typename ValueType , typename KeyComp = DefaultKeyComparer<KeyType>>
template<typename Predicate >
const ValueType * TLruCache< KeyType, ValueType, KeyComp >::FindByPredicate ( Predicate  Pred) const
inline

Find the value of an entry using a predicate.

参数
PredThe predicate functor to apply to each entry.
返回
A value for which the predicate returned true, or nullptr if not found.
参见
ContainsByPredicate, FilterByPredicate, RemoveByPredicate

◆ FindChecked()

template<typename KeyType , typename ValueType , typename KeyComp = DefaultKeyComparer<KeyType>>
FORCEINLINE const ValueType & TLruCache< KeyType, ValueType, KeyComp >::FindChecked ( const KeyType &  Key) const
inline

Find the value of the entry with the specified key.

参数
KeyThe key of the entry to get.
返回
Reference to the value, or triggers an assertion if the key does not exist.

◆ FindRef()

template<typename KeyType , typename ValueType , typename KeyComp = DefaultKeyComparer<KeyType>>
FORCEINLINE ValueType TLruCache< KeyType, ValueType, KeyComp >::FindRef ( const KeyType &  Key) const
inline

Find the value of the entry with the specified key.

参数
KeyThe key of the entry to get.
返回
Copy of the value, or the default value for the ValueType if the key does not exist.

◆ GetKeys()

template<typename KeyType , typename ValueType , typename KeyComp = DefaultKeyComparer<KeyType>>
void TLruCache< KeyType, ValueType, KeyComp >::GetKeys ( TArray< KeyType > &  OutKeys) const
inline

Find the keys of all cached entries.

参数
OutKeysWill contain the collection of keys.
参见
Add, Empty, Find

◆ MarkAsRecent()

template<typename KeyType , typename ValueType , typename KeyComp = DefaultKeyComparer<KeyType>>
FORCEINLINE void TLruCache< KeyType, ValueType, KeyComp >::MarkAsRecent ( FCacheEntry &  Entry)
inlineprotected

Mark the given entry as recently used.

参数
EntryThe entry to mark.

◆ Max()

template<typename KeyType , typename ValueType , typename KeyComp = DefaultKeyComparer<KeyType>>
FORCEINLINE int32 TLruCache< KeyType, ValueType, KeyComp >::Max ( ) const
inline

Get the maximum number of entries in the cache.

返回
Maximum number of entries.
参见
Empty, Num

◆ Num()

template<typename KeyType , typename ValueType , typename KeyComp = DefaultKeyComparer<KeyType>>
FORCEINLINE int32 TLruCache< KeyType, ValueType, KeyComp >::Num ( ) const
inline

Get the number of entries in the cache.

返回
Number of entries.
参见
Empty, Max

◆ Remove() [1/2]

template<typename KeyType , typename ValueType , typename KeyComp = DefaultKeyComparer<KeyType>>
void TLruCache< KeyType, ValueType, KeyComp >::Remove ( const KeyType &  Key)
inline

Remove all entries with the specified key from the cache.

参数
KeyThe key of the entries to remove.
参见
Add, Empty, Find, RemoveByPredicate

◆ Remove() [2/2]

template<typename KeyType , typename ValueType , typename KeyComp = DefaultKeyComparer<KeyType>>
FORCEINLINE void TLruCache< KeyType, ValueType, KeyComp >::Remove ( FCacheEntry *  Entry)
inlineprotected

Remove the specified entry from the cache.

参数
EntryThe entry to remove.

◆ RemoveByPredicate()

template<typename KeyType , typename ValueType , typename KeyComp = DefaultKeyComparer<KeyType>>
template<typename Predicate >
int32 TLruCache< KeyType, ValueType, KeyComp >::RemoveByPredicate ( Predicate  Pred)
inline

Remove all entries using a predicate.

参数
PredThe predicate function to apply to each entry.
返回
Number of removed entries.
参见
ContainsByPredicate, FilterByPredicate, FindByPredicate, Remove

◆ RemoveLeastRecent()

template<typename KeyType , typename ValueType , typename KeyComp = DefaultKeyComparer<KeyType>>
FORCEINLINE ValueType TLruCache< KeyType, ValueType, KeyComp >::RemoveLeastRecent ( )
inline

Remove and return the least recent element from the cache.

返回
Copy of removed value.

该类的文档由以下文件生成: