Skip to content

Commit

Permalink
impl_v3 for q460: clear freq_map entry if its corresponding list is e…
Browse files Browse the repository at this point in the history
…mpty
  • Loading branch information
drink7036290 committed Nov 30, 2024
1 parent 2340284 commit a81bcf0
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions implementations/q460_lfu_cache/src/impl_v3.rs
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,11 @@ impl LFUCache {
if let Some(freq_list) = self.freq_map.get_mut(&freq) {
freq_list.remove(node_rc.clone());

if freq_list.is_empty() && (self.min_freq == freq) {
self.min_freq += 1;
if freq_list.is_empty() {
self.freq_map.remove(&freq);
if self.min_freq == freq {
self.min_freq += 1;
}
}
}

Expand Down

0 comments on commit a81bcf0

Please sign in to comment.