mirror of
https://github.com/krahets/hello-algo.git
synced 2026-08-15 21:20:58 +00:00
feat(csharp) .NET 8.0 code migration (#966)
* .net 8.0 migration * update docs * revert change * revert change and update appendix docs * remove static * Update binary_search_insertion.cs * Update binary_search_insertion.cs * Update binary_search_edge.cs * Update binary_search_insertion.cs * Update binary_search_edge.cs --------- Co-authored-by: Yudong Jin <krahets@163.com>
This commit is contained in:
@@ -9,11 +9,11 @@ namespace hello_algo.chapter_heap;
|
||||
/* 大顶堆 */
|
||||
class MaxHeap {
|
||||
// 使用列表而非数组,这样无须考虑扩容问题
|
||||
private readonly List<int> maxHeap;
|
||||
List<int> maxHeap;
|
||||
|
||||
/* 构造函数,建立空堆 */
|
||||
public MaxHeap() {
|
||||
maxHeap = new List<int>();
|
||||
maxHeap = [];
|
||||
}
|
||||
|
||||
/* 构造函数,根据输入列表建堆 */
|
||||
@@ -130,7 +130,7 @@ public class my_heap {
|
||||
[Test]
|
||||
public void Test() {
|
||||
/* 初始化大顶堆 */
|
||||
MaxHeap maxHeap = new(new int[] { 9, 8, 6, 6, 7, 5, 2, 1, 4, 3, 6, 2 });
|
||||
MaxHeap maxHeap = new([9, 8, 6, 6, 7, 5, 2, 1, 4, 3, 6, 2]);
|
||||
Console.WriteLine("\n输入列表并建堆后");
|
||||
maxHeap.Print();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user