Change remove to pop (#1309)

This commit is contained in:
rongyi 2024-04-28 20:47:03 +08:00 committed by GitHub
parent 71b7cc8ef6
commit a88c7b9862
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -96,7 +96,7 @@ impl MaxHeap {
// 交换根节点与最右叶节点(交换首元素与尾元素) // 交换根节点与最右叶节点(交换首元素与尾元素)
self.swap(0, self.size() - 1); 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); self.sift_down(0);
// 返回堆顶元素 // 返回堆顶元素