fix(Go): Update array_queue.go and array_deque.go (#1362)

* 🐞 fix: 队列为空时不应该操作指向

* 🧪 test: 添加pop测试用例

* 🔧 build: 修改testify依赖包

* 🐞 fix: 双向队列为空时,pop不操作指向

* 🔧 build:

Remove third-party packages

* Delete codes/go/go.sum

---------

Co-authored-by: Yudong Jin <krahets@163.com>
This commit is contained in:
nil
2024-05-31 17:38:27 +08:00
committed by GitHub
parent 3f4220de81
commit 0774920d7f
3 changed files with 14 additions and 0 deletions

View File

@ -49,6 +49,10 @@ func (q *arrayQueue) push(num int) {
/* 出队 */
func (q *arrayQueue) pop() any {
num := q.peek()
if num == nil {
return nil
}
// 队首指针向后移动一位,若越过尾部,则返回到数组头部
q.front = (q.front + 1) % q.queCapacity
q.queSize--