| 100 | |
| 101 | private: |
| 102 | void evict_if_needed() { |
| 103 | while (cur_bytes_ > max_bytes_ && !order_.empty()) { |
| 104 | std::size_t victim = order_.back(); |
| 105 | auto it = map_.find(victim); |
| 106 | if (it != map_.end()) { |
| 107 | cur_bytes_ -= it->second.bytes.size(); |
| 108 | map_.erase(it); |
| 109 | } |
| 110 | order_.pop_back(); |
| 111 | } |
| 112 | } |
| 113 | |
| 114 | struct Entry { |
| 115 | std::list<std::size_t>::iterator it; |