LibreOffice Module stoc (master) 1
|
Implementation of a least recently used (lru) cache. More...
#include <lru_cache.h>
Classes | |
struct | Entry |
Public Member Functions | |
lru_cache () | |
Default Ctor. More... | |
t_val const * | lookup (t_key const &key) const |
Retrieves a pointer to value in cache. More... | |
void | set (t_key const &key, t_val const &val) |
Sets a value to be cached for given key. More... | |
void | setSize (::std::size_t size) |
Sets the number of elements to be cached. More... | |
Private Types | |
typedef std::unordered_map< t_key, Entry *, t_hashKey, t_equalKey > | t_key2element |
Private Member Functions | |
void | toFront (Entry *entry) const |
Private Attributes | |
t_key2element | m_key2element |
::std::size_t | m_size |
std::unique_ptr< Entry[]> | m_block |
Entry * | m_head |
Entry * | m_tail |
Implementation of a least recently used (lru) cache.
Definition at line 41 of file lru_cache.h.
|
private |
Definition at line 50 of file lru_cache.h.
|
inline |
|
inline |
Retrieves a pointer to value in cache.
Returns 0, if none was found.
key | a key |
Definition at line 139 of file lru_cache.h.
References stoc_sec::lru_cache< t_key, t_val, t_hashKey, t_equalKey >::Entry::m_key, stoc_sec::lru_cache< t_key, t_val, t_hashKey, t_equalKey >::Entry::m_val, and SAL_INFO.
|
inline |
Sets a value to be cached for given key.
key | a key |
val | a value |
Definition at line 163 of file lru_cache.h.
References stoc_sec::lru_cache< t_key, t_val, t_hashKey, t_equalKey >::Entry::m_key, stoc_sec::lru_cache< t_key, t_val, t_hashKey, t_equalKey >::Entry::m_val, and SAL_INFO.
|
inline |
Sets the number of elements to be cached.
This will clear previous entries.
cacheSize | number of elements to be cached |
Definition at line 86 of file lru_cache.h.
References stoc_sec::lru_cache< t_key, t_val, t_hashKey, t_equalKey >::Entry::m_pred, nPos, and size.
|
inlineprivate |
Definition at line 116 of file lru_cache.h.
References stoc_sec::lru_cache< t_key, t_val, t_hashKey, t_equalKey >::Entry::m_pred, and stoc_sec::lru_cache< t_key, t_val, t_hashKey, t_equalKey >::Entry::m_succ.
|
private |
Definition at line 54 of file lru_cache.h.
|
mutableprivate |
Definition at line 55 of file lru_cache.h.
|
private |
Definition at line 51 of file lru_cache.h.
|
private |
Definition at line 52 of file lru_cache.h.
|
mutableprivate |
Definition at line 56 of file lru_cache.h.