mirror of
https://github.com/krahets/hello-algo.git
synced 2026-04-09 13:51:48 +08:00
refactor: Replace poll with pop in Queue and Deque (#415)
This commit is contained in:
@@ -25,9 +25,9 @@ enum Queue {
|
||||
print("队首元素 peek = \(peek)")
|
||||
|
||||
/* 元素出队 */
|
||||
// 使用 Array 模拟时 poll 的复杂度为 O(n)
|
||||
// 使用 Array 模拟时 pop 的复杂度为 O(n)
|
||||
let pool = queue.removeFirst()
|
||||
print("出队元素 poll = \(pool),出队后 queue = \(queue)")
|
||||
print("出队元素 pop = \(pool),出队后 queue = \(queue)")
|
||||
|
||||
/* 获取队列的长度 */
|
||||
let size = queue.count
|
||||
|
||||
Reference in New Issue
Block a user