This commit is contained in:
krahets
2023-02-11 18:21:44 +08:00
parent 76dcc6cbd3
commit 58ad2290b0
20 changed files with 418 additions and 219 deletions
+11 -4
View File
@@ -362,7 +362,11 @@ comments: true
=== "C"
```c title="my_heap.c"
[class]{maxHeap}-[func]{left}
[class]{maxHeap}-[func]{right}
[class]{maxHeap}-[func]{parent}
```
=== "C#"
@@ -472,7 +476,7 @@ comments: true
=== "C"
```c title="my_heap.c"
[class]{maxHeap}-[func]{peek}
```
=== "C#"
@@ -668,7 +672,9 @@ comments: true
=== "C"
```c title="my_heap.c"
[class]{maxHeap}-[func]{push}
[class]{maxHeap}-[func]{siftUp}
```
=== "C#"
@@ -821,8 +827,7 @@ comments: true
void poll() {
// 判空处理
if (empty()) {
cout << "Error:堆为空" << endl;
return;
throw out_of_range("堆为空");
}
// 交换根结点与最右叶结点(即交换首元素与尾元素)
swap(maxHeap[0], maxHeap[size() - 1]);
@@ -977,7 +982,9 @@ comments: true
=== "C"
```c title="my_heap.c"
[class]{maxHeap}-[func]{poll}
[class]{maxHeap}-[func]{siftDown}
```
=== "C#"
@@ -1156,7 +1163,7 @@ comments: true
=== "C"
```c title="my_heap.c"
[class]{maxHeap}-[func]{newMaxHeap}
```
=== "C#"