diff --git a/libs/interval_heap/src/lib.rs b/libs/interval_heap/src/lib.rs index 920e0c22..b8956569 100644 --- a/libs/interval_heap/src/lib.rs +++ b/libs/interval_heap/src/lib.rs @@ -38,13 +38,11 @@ impl IntervalHeap { /// Removes and returns $\max(S)$. pub fn pop_max(&mut self) -> Option { - if self.values.len() <= 1 { + if self.values.len() <= 2 { return self.values.pop(); } let ret = self.values.swap_remove(1); - if self.values.len() >= 3 { - max_heapify_down(&mut self.values, 1); - } + max_heapify_down(&mut self.values, 1); Some(ret) }