mirror of
https://github.com/krahets/hello-algo.git
synced 2026-08-12 20:00:58 +00:00
refactor: Replace 'poll' with 'pop' in Heap (#416)
This commit is contained in:
@@ -76,7 +76,7 @@ func TestMyHeap(t *testing.T) {
|
||||
maxHeap.print()
|
||||
|
||||
/* 堆顶元素出堆 */
|
||||
peek = maxHeap.poll()
|
||||
peek = maxHeap.pop()
|
||||
fmt.Printf("\n堆顶元素 %d 出堆后\n", peek)
|
||||
maxHeap.print()
|
||||
|
||||
|
||||
@@ -94,7 +94,7 @@ func (h *maxHeap) siftUp(i int) {
|
||||
}
|
||||
|
||||
/* 元素出堆 */
|
||||
func (h *maxHeap) poll() any {
|
||||
func (h *maxHeap) pop() any {
|
||||
// 判空处理
|
||||
if h.isEmpty() {
|
||||
fmt.Println("error")
|
||||
|
||||
Reference in New Issue
Block a user