11 ,
typename EvalFunc=
int
27 void clear (
bool keepstats =
false) {
44 ResType
eval (
const FuncType & func,
const ParamType & param)
const {
45 return func.eval(param);
54 std::pair<bool,ResType>
55 insert(
const FuncType& hom,
const ParamType& node)
61 found =
cache_.
find ( access, std::make_pair(hom,node));
63 return std::make_pair(
false, access->second);
67 ResType result =
eval(hom, node);
72 bool insertion =
cache_.
insert ( access, std::make_pair(hom,node));
75 access->second = result;
77 return std::make_pair(insertion,result);
80 return std::make_pair (
false, result);
84 std::map<std::string, size_t> get_hits()
const {
return cache_.get_hits(); }
85 std::map<std::string, size_t> get_misses()
const {
return cache_.get_misses(); }
86 std::map<std::string, size_t> get_bounces()
const {
return cache_.get_bounces(); }
size_t peak_
Definition: Cache.hh:16
bool should_insert(const FuncType &) const
Definition: Cache.hh:49
size_t peak() const
Definition: Cache.hh:32
hash_map< std::pair< FuncType, ParamType >, ResType >::type hash_map
Definition: Cache.hh:19
std::pair< bool, ResType > insert(const FuncType &hom, const ParamType &node)
Definition: Cache.hh:55
void clear(bool keepstats=false)
clear the cache, discarding all values.
Definition: Cache.hh:27
hash_map cache_
Definition: Cache.hh:20
Cache(size_t s)
Definition: Cache.hh:24
Cache()
Definition: Cache.hh:23
ResType eval(const FuncType &func, const ParamType ¶m) const
Definition: Cache.hh:44
size_t size() const
Definition: Cache.hh:40
Definition: ext_hash_map.hh:96
Definition: ext_hash_map.hh:38
Definition: ext_hash_map.hh:21
size_type size() const
Definition: ext_hash_map.hh:199
bool find(accessor &result, const Key &key)
Definition: ext_hash_map.hh:217
bool insert(accessor &result, const Key &key)
Definition: ext_hash_map.hh:235
void clear()
Definition: ext_hash_map.hh:211