From a88c7b986227a73bbc34d857f2649ad09a393758 Mon Sep 17 00:00:00 2001 From: rongyi Date: Sun, 28 Apr 2024 20:47:03 +0800 Subject: [PATCH] Change remove to pop (#1309) --- codes/rust/chapter_heap/my_heap.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/codes/rust/chapter_heap/my_heap.rs b/codes/rust/chapter_heap/my_heap.rs index 67688d1a2..b087c194f 100644 --- a/codes/rust/chapter_heap/my_heap.rs +++ b/codes/rust/chapter_heap/my_heap.rs @@ -96,7 +96,7 @@ impl MaxHeap { // 交换根节点与最右叶节点(交换首元素与尾元素) self.swap(0, self.size() - 1); // 删除节点 - let val = self.max_heap.remove(self.size() - 1); + let val = self.max_heap.pop().unwrap(); // 从顶至底堆化 self.sift_down(0); // 返回堆顶元素