mirror of
https://github.com/krahets/hello-algo.git
synced 2026-05-04 00:20:26 +08:00
refactor: Replace 'poll' with 'pop' in Heap (#416)
This commit is contained in:
@@ -81,7 +81,7 @@ class MaxHeap {
|
||||
}
|
||||
|
||||
/* 元素出堆 */
|
||||
func poll() -> Int {
|
||||
func pop() -> Int {
|
||||
// 判空处理
|
||||
if isEmpty() {
|
||||
fatalError("堆为空")
|
||||
@@ -148,7 +148,7 @@ enum MyHeap {
|
||||
maxHeap.print()
|
||||
|
||||
/* 堆顶元素出堆 */
|
||||
peek = maxHeap.poll()
|
||||
peek = maxHeap.pop()
|
||||
print("\n堆顶元素 \(peek) 出堆后")
|
||||
maxHeap.print()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user