mirror of
https://github.com/krahets/hello-algo.git
synced 2026-04-02 02:02:57 +08:00
feat: add ArrayDeque (#348)
* 双向队列: java 代码 * 双向队列: markdown 内容 * Rewrite array_deque.java Update array_queue.java, linkedlist_deque.java * Add ArrayDeque figures and rewrite the contents --------- Co-authored-by: krahets <krahets@163.com>
This commit is contained in:
@@ -62,7 +62,7 @@ void push(ArrayQueue *queue, int num) {
|
||||
// 计算队尾指针,指向队尾索引 + 1
|
||||
// 通过取余操作,实现 rear 越过数组尾部后回到头部
|
||||
int rear = (queue->front + queue->queSize) % queue->queCapacity;
|
||||
// 尾结点后添加 num
|
||||
// 将 num 添加至队尾
|
||||
queue->nums[rear] = num;
|
||||
queue->queSize++;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user