heap 包源码阅读

最近在练习leetcode题目时,需要用到堆,发现 Golang 标准库已经有heap包,在使用的同时也看看源码的写法。

1. 堆的定义

In computer science, a heap is a specialized tree-based data structure that satisfies the heap property: In a max heap, for any given node C, if P is a parent node of C, then the key (the value) of P is greater than or equal to the key of C. In a min heap, the key of P is less than or equal to the key of C.


Kesa...大约 5 分钟golangwhy