Include file:

#include "mcrl2/utilities/fixed_size_cache.h
class mcrl2::utilities::function_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.

Private types

type mcrl2::utilities::function_cache::super

typedef for fixed_size_cache< Policy >

Private attributes

F mcrl2::utilities::function_cache::m_cached_function

The function of which the results are cached.

Policy::map_type mcrl2::utilities::function_cache::m_map

The underlying mapping from keys to their cached results.

std::size_t mcrl2::utilities::function_cache::m_maximum_size

The maximum number of elements to cache.

Policy mcrl2::utilities::function_cache::m_policy

The replacement policy for keys in the cache.

Public member functions

function_cache(F cached_function = F(), std::size_t max_size = 1024)
auto operator()(Args args) -> typename std::result_of< F(Args)>::type

Stores the given key-value pair in the cache. Depending on the cache policy and capacity an existing element might be removed.

Private member functions

iterator find(const key_type &key)