Fix confusion between queSize and rear pointer in ArrayQueue implementation (#1851)

- `queSize` represents the queue's size, not the rear pointer position.
- In `pop`, `queSize--` decreases the size, not the rear pointer.
- The rear pointer is calculated using modulo (`%`) with the `front` and `queSize` to avoid confusion.

Co-authored-by: Chance Luo <247349913+chanceluo1618-bot@users.noreply.github.com>
This commit is contained in:
Kunchen-Luo
2026-03-30 14:46:56 +08:00
committed by GitHub
parent 6251b8e232
commit c2eb1dbc5a

View File

@@ -10,7 +10,7 @@
typedef struct {
int *nums; // 用于存储队列元素的数组
int front; // 队首指针,指向队首元素
int queSize; // 尾指针,指向队尾 + 1
int queSize; // 当前队列的元素数量
int queCapacity; // 队列容量
} ArrayQueue;