Skip to content

feat: Add circular queue data structure implementation #70

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion Data-Structures/CircularQueue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,13 @@
* @class CircularQueue
* @description Circular implementation of a queue
*/
export class CircularQueue<T> {
export interface Queue<T> {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No. That way you still get rid of the non-circular Queue implementation. I want there to be two Queue classes, one circular and the other one not circular. They may both implement a common interface.

push(value: T): void;
pop(): T;
length(): number;
}

export class CircularQueue<T> implements Queue<T> {
private queue: T[];
private limit: number;
private frontIdx: number;
Expand Down