From c7d94ab73c1dfc9c64b6b60414b2b1bd73608ef6 Mon Sep 17 00:00:00 2001 From: Nagata Kana Date: Thu, 4 Apr 2024 20:32:40 +0900 Subject: [PATCH] fix IntervalHeap::pop_max --- libs/interval_heap/src/lib.rs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) 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) }