Skip to content

Fix confusion between queSize and rear pointer in ArrayQueue implemen…#1851

Open
Kunchen-Luo wants to merge 1 commit intokrahets:mainfrom
Kunchen-Luo:main
Open

Fix confusion between queSize and rear pointer in ArrayQueue implemen…#1851
Kunchen-Luo wants to merge 1 commit intokrahets:mainfrom
Kunchen-Luo:main

Conversation

@Kunchen-Luo
Copy link

This PR clarifies the meaning of queSize in the ArrayQueue implementation.

queSize represents the current size of the queue rather than the rear pointer position.
In the pop function, queSize-- decreases the queue size, which could be confusing for beginners if interpreted as moving the rear pointer.
The rear index is actually calculated using modulo (%) with front and queSize.

This change only improves comments and readability; no functional logic is modified.
Please let me know if any adjustments are needed. Thanks!

…tation

- `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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant