Class LruCache

template<typename key_t, typename value_t, class hash_t = std::hash<key_t>>
class LruCache

Public Types

template<>
using const_list_iterator_t = typename cache_list_t::const_iterator

Public Functions

LruCache(const size_t max_size)
void put(const key_t &key, value_t &&value)
void put(const key_t &key, const value_t &value)
value_t *get(const key_t &key)
const_list_iterator_t find(const key_t &key) const
const_list_iterator_t cend() const
void clear()
void evictFractionEntries(const float fraction)
void evictNEntries(const size_t n)
size_t size() const

Private Types

template<>
using key_value_pair_t = typename std::pair<key_t, value_t>
template<>
using cache_list_t = typename std::list<key_value_pair_t>
template<>
using list_iterator_t = typename cache_list_t::iterator
template<>
using map_t = typename std::unordered_map<key_t, list_iterator_t, hash_t>
template<>
using map_t_iterator = typename map_t::iterator

Private Functions

void putCommon(map_t_iterator &it, key_t const &key)
void evictCommon(const size_t entries_to_evict)

Private Members

cache_list_t cache_items_list_
map_t cache_items_map_
size_t max_size_