mCRL2
|
A cache keeps track of key-value pairs similar to a map. The difference is that a cache has (an optional) maximum size and a policy that determines what element gets evicted when the cache is full. More...
#include <fixed_size_cache.h>
Public Types | |
using | key_type = typename Policy::key_type |
using | iterator = typename Policy::map_type::iterator |
using | const_iterator = typename Policy::map_type::const_iterator |
Public Member Functions | |
fixed_size_cache (std::size_t max_size=1024) | |
const_iterator | begin () const |
const_iterator | end () const |
void | clear () |
std::size_t | count (const key_type &key) const |
iterator | find (const key_type &key) |
template<typename ... Args> | |
std::pair< iterator, bool > | emplace (Args &&... args) |
Stores the given key-value pair in the cache. Depending on the cache policy and capacity an existing element might be removed. | |
Protected Attributes | |
Policy::map_type | m_map |
The underlying mapping from keys to their cached results. | |
Policy | m_policy |
The replacement policy for keys in the cache. | |
std::size_t | m_maximum_size |
The maximum number of elements to cache. | |
A cache keeps track of key-value pairs similar to a map. The difference is that a cache has (an optional) maximum size and a policy that determines what element gets evicted when the cache is full.
Works with arbirary maps that implement the unordered_map interface.
Definition at line 26 of file fixed_size_cache.h.
using mcrl2::utilities::fixed_size_cache< Policy >::const_iterator = typename Policy::map_type::const_iterator |
Definition at line 31 of file fixed_size_cache.h.
using mcrl2::utilities::fixed_size_cache< Policy >::iterator = typename Policy::map_type::iterator |
Definition at line 30 of file fixed_size_cache.h.
using mcrl2::utilities::fixed_size_cache< Policy >::key_type = typename Policy::key_type |
Definition at line 29 of file fixed_size_cache.h.
|
inlineexplicit |
Definition at line 33 of file fixed_size_cache.h.
|
inline |
Definition at line 48 of file fixed_size_cache.h.
|
inline |
Definition at line 51 of file fixed_size_cache.h.
|
inline |
Definition at line 53 of file fixed_size_cache.h.
|
inline |
Stores the given key-value pair in the cache. Depending on the cache policy and capacity an existing element might be removed.
Definition at line 63 of file fixed_size_cache.h.
|
inline |
Definition at line 49 of file fixed_size_cache.h.
|
inline |
Definition at line 55 of file fixed_size_cache.h.
|
protected |
The underlying mapping from keys to their cached results.
Definition at line 89 of file fixed_size_cache.h.
|
protected |
The maximum number of elements to cache.
Definition at line 92 of file fixed_size_cache.h.
|
protected |
The replacement policy for keys in the cache.
Definition at line 90 of file fixed_size_cache.h.