13 #include <type_traits>
14 #include <unordered_map>
24 template <
typename key_t,
typename value_t,
class hash_t = std::hash<key_t>>
30 using map_t =
typename std::unordered_map<key_t, list_iterator_t, hash_t>;
39 size_t put(
const key_t& key, value_t&& value) {
46 size_t put(
const key_t& key,
const value_t& value) {
62 value_t*
get(
const key_t& key) {
68 return &it->second->second;
94 static_cast<size_t>(1)),
109 size_t entries_erased = 0;
130 return entries_erased;
135 size_t entries_erased = 0;
143 return entries_erased;
149 return value ? value->size() : 0;
typename std::unordered_map< CompilationContext, list_iterator_t, std::hash< CompilationContext > > map_t
size_t getValueSize(const list_iterator_t &it)
typename cache_list_t::iterator list_iterator_t
size_t computeNumEntriesToEvict(const float fraction)
LruCache(EvictionMetricType eviction_metric_type, const size_t max_size)
void erase(const key_t &key)
size_t putCommon(map_t_iterator &it, key_t const &key)
size_t put(const key_t &key, const value_t &value)
typename std::pair< CompilationContext, value_t > key_value_pair_t
size_t put(const key_t &key, value_t &&value)
size_t evictCommon(const size_t entries_to_evict)
size_t evictNEntries(const size_t n)
const_list_iterator_t cend() const
const_list_iterator_t cbegin() const
cache_list_t cache_items_list_
EvictionMetricType eviction_metric_type_
typename map_t::iterator map_t_iterator
typename std::list< key_value_pair_t > cache_list_t
size_t getValueSize(const value_t &value)
const_list_iterator_t find(const key_t &key) const
typename cache_list_t::const_iterator const_list_iterator_t