Skip to content

Commit

Permalink
Change remove to pop (krahets#1309)
Browse files Browse the repository at this point in the history
  • Loading branch information
rongyi authored Apr 28, 2024
1 parent 71b7cc8 commit a88c7b9
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion codes/rust/chapter_heap/my_heap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
// 返回堆顶元素
Expand Down

0 comments on commit a88c7b9

Please sign in to comment.