Open 3D Engine AtomCore API Reference 23.10.0
O3DE is an open-source, fully-featured, high-fidelity, modular 3D engine for building games and simulations, available to every industry.
AZStd::lru_cache< KeyType, MappedType, Hasher, EqualKey, Allocator > Class Template Reference

#include <lru_cache.h>

Public Types

typedef KeyType key_type
 
typedef MappedType mapped_type
 
typedef pair< KeyType, MappedType > value_type
 
typedef list< value_type, Allocator > list_type
 
typedef list_type::iterator iterator
 
typedef list_type::const_iterator const_iterator
 
typedef list_type::reverse_iterator reverse_iterator
 
typedef list_type::const_reverse_iterator const_reverse_iterator
 
typedef pair< iterator, bool > pair_iter_bool
 

Public Member Functions

 lru_cache (size_t capacity)
 
pair_iter_bool insert (const KeyType &key, const MappedType &value)
 
template<typename... Args>
pair_iter_bool emplace (const KeyType &key, Args &&... arguments)
 
iterator get (const KeyType &key)
 
bool exists (const key_type &key) const
 
void set_capacity (size_t capacity)
 
void clear ()
 
size_t capacity () const
 
size_t size () const
 
bool empty () const
 
iterator begin ()
 
const_iterator begin () const
 
iterator end ()
 
const_iterator end () const
 
reverse_iterator rbegin ()
 
const_reverse_iterator rbegin () const
 
reverse_iterator rend ()
 
const_reverse_iterator rend () const
 

Detailed Description

template<typename KeyType, typename MappedType, class Hasher = AZStd::hash<KeyType>, class EqualKey = AZStd::equal_to<KeyType>, class Allocator = AZStd::allocator>
class AZStd::lru_cache< KeyType, MappedType, Hasher, EqualKey, Allocator >

This class is a simple map which keeps an least-recently-used list of elements. If the capacity of the map is exceeded with a new insertion, the oldest element is evicted.

Member Function Documentation

◆ emplace()

template<typename KeyType , typename MappedType , class Hasher = AZStd::hash<KeyType>, class EqualKey = AZStd::equal_to<KeyType>, class Allocator = AZStd::allocator>
template<typename... Args>
pair_iter_bool AZStd::lru_cache< KeyType, MappedType, Hasher, EqualKey, Allocator >::emplace ( const KeyType &  key,
Args &&...  arguments 
)
inline

Constructs a new MappedType with the provided arguments, associated with key. If the key already exists, replaces the existing mapped type. The entry is promoted to the most-recently-used.

◆ exists()

template<typename KeyType , typename MappedType , class Hasher = AZStd::hash<KeyType>, class EqualKey = AZStd::equal_to<KeyType>, class Allocator = AZStd::allocator>
bool AZStd::lru_cache< KeyType, MappedType, Hasher, EqualKey, Allocator >::exists ( const key_type &  key) const
inline

Returns whether the key exists in the container. Does not promote the entry.

◆ get()

template<typename KeyType , typename MappedType , class Hasher = AZStd::hash<KeyType>, class EqualKey = AZStd::equal_to<KeyType>, class Allocator = AZStd::allocator>
iterator AZStd::lru_cache< KeyType, MappedType, Hasher, EqualKey, Allocator >::get ( const KeyType &  key)
inline

Returns the mapped type based on the key. The entry is promoted to be the most recently used.

◆ insert()

template<typename KeyType , typename MappedType , class Hasher = AZStd::hash<KeyType>, class EqualKey = AZStd::equal_to<KeyType>, class Allocator = AZStd::allocator>
pair_iter_bool AZStd::lru_cache< KeyType, MappedType, Hasher, EqualKey, Allocator >::insert ( const KeyType &  key,
const MappedType &  value 
)
inline

Inserts \rev value associated with key. If the key already exists, replaces the existing value. The entry is promoted to the most-recently-used.

◆ set_capacity()

template<typename KeyType , typename MappedType , class Hasher = AZStd::hash<KeyType>, class EqualKey = AZStd::equal_to<KeyType>, class Allocator = AZStd::allocator>
void AZStd::lru_cache< KeyType, MappedType, Hasher, EqualKey, Allocator >::set_capacity ( size_t  capacity)
inline

Adjusts the capacity of the container. If the new capacity is smaller than the existing size, elements will be evicted until the capacity is reached.


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