| 287 | } |
| 288 | |
| 289 | fn evict_lru(&self) { |
| 290 | let mut oldest_pair = None; |
| 291 | let mut oldest_counter = u32::MAX; |
| 292 | |
| 293 | for entry in self.map.iter() { |
| 294 | let (key, (_, counter_val)) = entry.pair(); |
| 295 | if *counter_val < oldest_counter { |
| 296 | oldest_counter = *counter_val; |
| 297 | oldest_pair = Some(key.clone()); |
| 298 | } |
| 299 | } |
| 300 | |
| 301 | if let Some(key) = oldest_pair { |
| 302 | if let Some((key, (value, _))) = self.map.remove(&key) { |
| 303 | if let Some(evict_hook) = self.evict_hook { |
| 304 | evict_hook(&value); |
| 305 | } |
| 306 | } |
| 307 | } |
| 308 | } |
| 309 | |
| 310 | fn evict_lru_probabilistic(&self, strategy: &ProbEviction) { |
| 311 | let num_to_evict = self |