mirror of
https://github.com/krahets/hello-algo.git
synced 2024-12-25 02:16:28 +08:00
fix poll() in my_heap.cpp (#360)
This commit is contained in:
parent
ea5677b3c6
commit
8d8b713865
1 changed files with 1 additions and 2 deletions
|
@ -99,8 +99,7 @@ public:
|
|||
void poll() {
|
||||
// 判空处理
|
||||
if (empty()) {
|
||||
cout << "Error:堆为空" << endl;
|
||||
return;
|
||||
throw out_of_range("堆为空");
|
||||
}
|
||||
// 交换根结点与最右叶结点(即交换首元素与尾元素)
|
||||
swap(maxHeap[0], maxHeap[size() - 1]);
|
||||
|
|
Loading…
Reference in a new issue