mirror of
https://github.com/krahets/hello-algo.git
synced 2024-12-26 01:36:29 +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() {
|
void poll() {
|
||||||
// 判空处理
|
// 判空处理
|
||||||
if (empty()) {
|
if (empty()) {
|
||||||
cout << "Error:堆为空" << endl;
|
throw out_of_range("堆为空");
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
// 交换根结点与最右叶结点(即交换首元素与尾元素)
|
// 交换根结点与最右叶结点(即交换首元素与尾元素)
|
||||||
swap(maxHeap[0], maxHeap[size() - 1]);
|
swap(maxHeap[0], maxHeap[size() - 1]);
|
||||||
|
|
Loading…
Reference in a new issue