| 64 | } |
| 65 | |
| 66 | void insert(const key_type &key, const value_type &value) |
| 67 | { |
| 68 | typename map_type::iterator i = m_map.find(key); |
| 69 | if(i == m_map.end()){ |
| 70 | // insert item into the cache, but first check if it is full |
| 71 | if(size() >= m_capacity){ |
| 72 | // cache is full, evict the least recently used item |
| 73 | evict(); |
| 74 | } |
| 75 | |
| 76 | // insert the new item |
| 77 | m_list.push_front(key); |
| 78 | m_map[key] = std::make_pair(value, m_list.begin()); |
| 79 | } |
| 80 | } |
| 81 | |
| 82 | boost::optional<value_type> get(const key_type &key) |
| 83 | { |
no test coverage detected