refactor: Replace poll with pop in Queue and Deque (#415)

This commit is contained in:
Yudong Jin
2023-03-13 21:58:21 +08:00
committed by GitHub
parent 2d17ee8e92
commit 8aebbaad21
77 changed files with 261 additions and 261 deletions

View File

@@ -46,7 +46,7 @@ class ArrayQueue {
/* */
@discardableResult
func poll() -> Int {
func pop() -> Int {
let num = peek()
//
front = (front + 1) % capacity()
@@ -94,8 +94,8 @@ enum _ArrayQueue {
print("队首元素 peek = \(peek)")
/* */
let poll = queue.poll()
print("出队元素 poll = \(poll),出队后 queue = \(queue.toArray())")
let pop = queue.pop()
print("出队元素 pop = \(pop),出队后 queue = \(queue.toArray())")
/* */
let size = queue.size()
@@ -108,7 +108,7 @@ enum _ArrayQueue {
/* */
for i in 0 ..< 10 {
queue.push(num: i)
queue.poll()
queue.pop()
print("\(i) 轮入队 + 出队后 queue = \(queue.toArray())")
}
}