fix poll() in my_heap.cpp (#360)

This commit is contained in:
LoneRanger 2023-02-11 18:04:29 +08:00 committed by GitHub
parent ea5677b3c6
commit 8d8b713865
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -99,8 +99,7 @@ public:
void poll() {
// 判空处理
if (empty()) {
cout << "Error:堆为空" << endl;
return;
throw out_of_range("堆为空");
}
// 交换根结点与最右叶结点(即交换首元素与尾元素)
swap(maxHeap[0], maxHeap[size() - 1]);