mirror of
https://github.com/krahets/hello-algo.git
synced 2024-12-24 04:26:30 +08:00
Change remove to pop (#1309)
This commit is contained in:
parent
71b7cc8ef6
commit
a88c7b9862
1 changed files with 1 additions and 1 deletions
|
@ -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);
|
||||
// 返回堆顶元素
|
||||
|
|
Loading…
Reference in a new issue