docs: add comments of the complexity to queue and deque

This commit is contained in:
nuomi1
2023-01-14 10:17:22 +08:00
parent 595aa93996
commit 007fbff65f
4 changed files with 4 additions and 0 deletions

View File

@ -212,6 +212,7 @@ comments: true
let peekLast = deque.last! // 队尾元素
/* 元素出队 */
// 使用 Array 模拟时 pollFirst 的复杂度为 O(n)
let pollFirst = deque.removeFirst() // 队首元素出队
let pollLast = deque.removeLast() // 队尾元素出队

View File

@ -246,6 +246,7 @@ comments: true
let peek = queue.first!
/* 元素出队 */
// 使用 Array 模拟时 poll 的复杂度为 O(n)
let pool = queue.removeFirst()
/* 获取队列的长度 */