mirror of
https://github.com/krahets/hello-algo.git
synced 2026-04-01 17:53:18 +08:00
build
This commit is contained in:
@@ -2830,6 +2830,9 @@ comments: true
|
||||
/* 队首出队 */
|
||||
func (q *arrayDeque) popFirst() any {
|
||||
num := q.peekFirst()
|
||||
if num == nil {
|
||||
return nil
|
||||
}
|
||||
// 队首指针向后移动一位
|
||||
q.front = q.index(q.front + 1)
|
||||
q.queSize--
|
||||
@@ -2839,6 +2842,9 @@ comments: true
|
||||
/* 队尾出队 */
|
||||
func (q *arrayDeque) popLast() any {
|
||||
num := q.peekLast()
|
||||
if num == nil {
|
||||
return nil
|
||||
}
|
||||
q.queSize--
|
||||
return num
|
||||
}
|
||||
|
||||
@@ -1762,6 +1762,10 @@ comments: true
|
||||
/* 出队 */
|
||||
func (q *arrayQueue) pop() any {
|
||||
num := q.peek()
|
||||
if num == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
// 队首指针向后移动一位,若越过尾部,则返回到数组头部
|
||||
q.front = (q.front + 1) % q.queCapacity
|
||||
q.queSize--
|
||||
|
||||
Reference in New Issue
Block a user