virtual size_t get_addr_hash (void const* p) { //!!! accept 'table size' to do 'hash % table_size' // will give more information for state exploration hash_map_t::iterator iter (hash_map_.find(p)); if (iter != hash_map_.end() && iter->first == p) { return iter->second; } else { //!!! distribute hashes more randomly, use rand() size_t hash = hash_seq_++; hash_map_.insert(std::make_pair(p, hash)); return hash; } }
void LRUCache::append(int key, int value) { lst_.emplace_front(key, value); pair<hash_iterator, bool> ret = hash_map_.insert(hash_value_type(key, lst_.begin())); if (!ret.second) ret.first->second = lst_.begin(); }