UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
TPsoLruCache< KeyType, ValueType > Class Template Reference

#include <PsoLruCache.h>

Classes

class  TBaseIterator
 
class  TConstIterator
 
class  TIterator
 

Public Member Functions

 TPsoLruCache ()
 
 TPsoLruCache (int32 InMaxNumElements)
 
 ~TPsoLruCache ()
 
FSetElementId Add (const KeyType &Key, const ValueType &Value)
 
bool Contains (const KeyType &Key) const
 
template<typename Predicate >
bool ContainsByPredicate (Predicate Pred) const
 
void Empty (int32 InMaxNumElements=0)
 
template<typename Predicate >
TArray< ValueType > FilterByPredicate (Predicate Pred) const
 
const ValueType * Find (const KeyType &Key) const
 
const ValueType * FindAndTouch (const KeyType &Key)
 
template<typename Predicate >
const ValueType * FindByPredicate (Predicate Pred) const
 
void GetKeys (TArray< KeyType > &OutKeys) const
 
int32 Max () const
 
int32 Num () const
 
void Remove (const KeyType &Key)
 
bool Remove (const KeyType &Key, ValueType &RemovedValue)
 
template<typename Predicate >
int32 RemoveByPredicate (Predicate Pred)
 
ValueType RemoveLeastRecent ()
 
const ValueType GetLeastRecent () const
 
ValueType RemoveMostRecent ()
 
void MarkAsRecent (const FSetElementId &LRUNode)
 

Protected Member Functions

void MarkAsRecent (FCacheEntry &Entry)
 
void Remove (FCacheEntry *Entry)
 

Friends

TIterator begin (TPsoLruCache &Cache)
 
TConstIterator begin (const TPsoLruCache &Cache)
 
TIterator end (TPsoLruCache &Cache)
 
TConstIterator end (const TPsoLruCache &Cache)
 

Constructor & Destructor Documentation

◆ TPsoLruCache() [1/2]

template<typename KeyType , typename ValueType >
TPsoLruCache< KeyType, ValueType >::TPsoLruCache ( )
inline

Default constructor (empty cache that cannot hold any values).

◆ TPsoLruCache() [2/2]

template<typename KeyType , typename ValueType >
TPsoLruCache< KeyType, ValueType >::TPsoLruCache ( int32  InMaxNumElements)
inline

Create and initialize a new instance.

Parameters
InMaxNumElementsThe maximum number of elements this cache can hold.

◆ ~TPsoLruCache()

template<typename KeyType , typename ValueType >
TPsoLruCache< KeyType, ValueType >::~TPsoLruCache ( )
inline

Destructor.

Member Function Documentation

◆ Add()

template<typename KeyType , typename ValueType >
FSetElementId TPsoLruCache< KeyType, ValueType >::Add ( const KeyType &  Key,
const ValueType &  Value 
)
inline

Add an entry to the cache.

The new entry must not exist in the cache, there must be space within the LRU for the new entry. The new entry will be marked as the most recently used one.

Parameters
KeyThe entry's lookup key.
ValueThe entry's value.
Returns
FSetElementId of the entry, update recent status without requiring a find operation.
See also
Empty, Find, GetKeys, Remove

◆ Contains()

template<typename KeyType , typename ValueType >
bool TPsoLruCache< KeyType, ValueType >::Contains ( const KeyType &  Key) const
inline

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

Parameters
KeyThe key of the entry to check.
Returns
true if the entry is in the cache, false otherwise.
See also
Add, ContainsByPredicate, Empty, FilterByPredicate, Find, GetKeys, Remove

◆ ContainsByPredicate()

template<typename KeyType , typename ValueType >
template<typename Predicate >
bool TPsoLruCache< KeyType, ValueType >::ContainsByPredicate ( Predicate  Pred) const
inline

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

Parameters
PredThe predicate functor to apply to each entry.
Returns
true if at least one matching entry is in the cache, false otherwise.
See also
Contains, FilterByPredicate, FindByPredicate, RemoveByPredicate

◆ Empty()

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

Empty the cache.

Parameters
InMaxNumElementsThe maximum number of elements this cache can hold (default = 0).
See also
Add, Find, GetKeys, Max, Num, Remove

◆ FilterByPredicate()

template<typename KeyType , typename ValueType >
template<typename Predicate >
TArray< ValueType > TPsoLruCache< KeyType, ValueType >::FilterByPredicate ( Predicate  Pred) const
inline

Filter the entries in the cache using a predicate.

Parameters
PredThe predicate functor to apply to each entry.
Returns
Collection of values for which the predicate returned true.
See also
ContainsByPredicate, FindByPredicate, Find, RemoveByPredicate

◆ Find()

template<typename KeyType , typename ValueType >
const ValueType * TPsoLruCache< KeyType, ValueType >::Find ( const KeyType &  Key) const
inline

Find the value of the entry with the specified key.

Parameters
KeyThe key of the entry to get.
Returns
Pointer to the value, or nullptr if not found.
See also
Add, Contains, Empty, FindAndTouch, GetKeys, Remove

◆ FindAndTouch()

template<typename KeyType , typename ValueType >
const ValueType * TPsoLruCache< KeyType, ValueType >::FindAndTouch ( const KeyType &  Key)
inline

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

Parameters
KeyThe key of the entry to get.
Returns
Pointer to the value, or nullptr if not found.
See also
Add, Contains, Empty, Find, GetKeys, Remove

◆ FindByPredicate()

template<typename KeyType , typename ValueType >
template<typename Predicate >
const ValueType * TPsoLruCache< KeyType, ValueType >::FindByPredicate ( Predicate  Pred) const
inline

Find the value of an entry using a predicate.

Parameters
PredThe predicate functor to apply to each entry.
Returns
Pointer to value for which the predicate returned true, or nullptr if not found.
See also
ContainsByPredicate, FilterByPredicate, RemoveByPredicate

◆ GetKeys()

template<typename KeyType , typename ValueType >
void TPsoLruCache< KeyType, ValueType >::GetKeys ( TArray< KeyType > &  OutKeys) const
inline

Find the keys of all cached entries.

Parameters
OutKeysWill contain the collection of keys.
See also
Add, Empty, Find

◆ GetLeastRecent()

template<typename KeyType , typename ValueType >
const ValueType TPsoLruCache< KeyType, ValueType >::GetLeastRecent ( ) const
inline

Return the least recent element from the cache.

Returns
Copy of the least recent value.

◆ MarkAsRecent() [1/2]

template<typename KeyType , typename ValueType >
void TPsoLruCache< KeyType, ValueType >::MarkAsRecent ( const FSetElementId LRUNode)
inline

◆ MarkAsRecent() [2/2]

template<typename KeyType , typename ValueType >
void TPsoLruCache< KeyType, ValueType >::MarkAsRecent ( FCacheEntry &  Entry)
inlineprotected

Mark the given entry as recently used.

Parameters
EntryThe entry to mark.

◆ Max()

template<typename KeyType , typename ValueType >
int32 TPsoLruCache< KeyType, ValueType >::Max ( ) const
inline

Get the maximum number of entries in the cache.

Returns
Maximum number of entries.
See also
Empty, Num

◆ Num()

template<typename KeyType , typename ValueType >
int32 TPsoLruCache< KeyType, ValueType >::Num ( ) const
inline

Get the number of entries in the cache.

Returns
Number of entries.
See also
Empty, Max

◆ Remove() [1/3]

template<typename KeyType , typename ValueType >
void TPsoLruCache< KeyType, ValueType >::Remove ( const KeyType &  Key)
inline

Remove all entries with the specified key from the cache.

Parameters
KeyThe key of the entries to remove.
See also
Add, Empty, Find, RemoveByPredicate

◆ Remove() [2/3]

template<typename KeyType , typename ValueType >
bool TPsoLruCache< KeyType, ValueType >::Remove ( const KeyType &  Key,
ValueType &  RemovedValue 
)
inline

◆ Remove() [3/3]

template<typename KeyType , typename ValueType >
void TPsoLruCache< KeyType, ValueType >::Remove ( FCacheEntry *  Entry)
inlineprotected

Remove the specified entry from the cache.

Parameters
EntryThe entry to remove.

◆ RemoveByPredicate()

template<typename KeyType , typename ValueType >
template<typename Predicate >
int32 TPsoLruCache< KeyType, ValueType >::RemoveByPredicate ( Predicate  Pred)
inline

Remove all entries using a predicate.

Parameters
PredThe predicate function to apply to each entry.
Returns
Number of removed entries.
See also
ContainsByPredicate, FilterByPredicate, FindByPredicate, Remove

◆ RemoveLeastRecent()

template<typename KeyType , typename ValueType >
ValueType TPsoLruCache< KeyType, ValueType >::RemoveLeastRecent ( )
inline

Remove and return the least recent element from the cache.

Returns
Copy of removed value.

◆ RemoveMostRecent()

template<typename KeyType , typename ValueType >
ValueType TPsoLruCache< KeyType, ValueType >::RemoveMostRecent ( )
inline

Remove and return the most recent element from the cache.

Returns
Copy of removed value.

Friends And Related Symbol Documentation

◆ begin [1/2]

template<typename KeyType , typename ValueType >
TConstIterator begin ( const TPsoLruCache< KeyType, ValueType > &  Cache)
friend

◆ begin [2/2]

template<typename KeyType , typename ValueType >
TIterator begin ( TPsoLruCache< KeyType, ValueType > &  Cache)
friend

◆ end [1/2]

template<typename KeyType , typename ValueType >
TConstIterator end ( const TPsoLruCache< KeyType, ValueType > &  Cache)
friend

◆ end [2/2]

template<typename KeyType , typename ValueType >
TIterator end ( TPsoLruCache< KeyType, ValueType > &  Cache)
friend

The documentation for this class was generated from the following file: