TLruCache

Syntax

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

Remarks

Implements a Least Recently Used (LRU) cache.

Constructors

Name Description

Public function

TLruCache()

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

Public function

TLruCache

(
    int32 InMaxNumElements
)

Create and initialize a new instance.

Destructors

Name Description

Public function

~TLruCache()

Destructor.

Functions

Name Description

Public function

void

 

Add

(
    const KeyType& Key,
    const ValueType& Value
)

Add an entry to the cache.

Public function Const

TConstIterat ...

 

begin()

Public function

TIterator

 

begin()

Public function Const

bool

 

Contains

(
    const KeyType& Key
)

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

Public function Const

bool

 

ContainsByPredicate

(
    Predicate Pred
)

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

Public function

void

 

Empty

(
    int32 InMaxNumElements
)

Empty the cache.

Public function Const

TConstIterat ...

 

end()

Public function

TIterator

 

end()

Public function Const

TArray < Valu...

 

FilterByPredicate

(
    Predicate Pred
)

Filter the entries in the cache using a predicate.

Public function Const

const ValueT...

 

Find

(
    const KeyType& Key
)

Find the value of the entry with the specified key.

Public function

const ValueT...

 

FindAndTouch

(
    const KeyType& Key
)

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

Public function

const ValueT...

 

FindAndTouchChecked

(
    const KeyType& Key
)

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

Public function

ValueType

 

FindAndTouchRef

(
    const KeyType& Key
)

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

Public function Const

const ValueT...

 

FindByPredicate

(
    Predicate Pred
)

Find the value of an entry using a predicate.

Public function Const

const ValueT...

 

FindChecked

(
    const KeyType& Key
)

Find the value of the entry with the specified key.

Public function Const

ValueType

 

FindRef

(
    const KeyType& Key
)

Find the value of the entry with the specified key.

Public function Const

void

 

GetKeys

(
    TArray < KeyType >& OutKeys
)

Find the keys of all cached entries.

Protected function

void

 

MarkAsRecent

(
    FCacheEntry& Entry
)

Mark the given entry as recently used.

Public function Const

int32

 

Max()

Get the maximum number of entries in the cache.

Public function Const

int32

 

Num()

Get the number of entries in the cache.

Public function

void

 

Remove

(
    const KeyType& Key
)

Remove all entries with the specified key from the cache.

Protected function

void

 

Remove

(
    FCacheEntry* Entry
)

Remove the specified entry from the cache.

Public function

int32

 

RemoveByPredicate

(
    Predicate Pred
)

Remove all entries using a predicate.

Public function

ValueType

 

RemoveLeastRecent()

Remove and return the least recent element from the cache.

Classes

Name

Description

Public class

TBaseIterator

Base class for cache iterators.

Iteration begins at the most recent entry.

Public class

TConstIterator

Cache iterator (const).

Public class

TIterator

Cache iterator.

References

Module

Core

Header

Runtime/Core/Public/Containers/LruCache.h