This pull request introduces a new implementation of a Circular Queue in JavaScript. The Circular Queue is a linear data structure that follows the First In First Out (FIFO) principle and efficiently utilizes memory by wrapping around when the end of the array is reached.
Changes Made
Added: A new file CircularQueue.js that contains the implementation of the Circular Queue.
Implemented:
constructor(capacity): Initializes the Circular Queue with a specified capacity.
isEmpty(): Checks if the queue is empty.
isFull(): Checks if the queue is full.
peek(): Reads the element at the front of the queue without removing it.
enqueue(value): Adds a new element to the end of the queue.
dequeue(): Removes the element at the front of the queue.
getSize(): Returns the current size of the queue.
toString(): Returns the string representation of the queue.
Motivation
The motivation behind this addition is to provide an efficient queue implementation that can handle wrap-around cases seamlessly. This is particularly useful for scenarios where memory utilization is crucial and can help in reducing memory overhead compared to a standard queue implementation.
Pull Request: Add Circular Queue Implementation
Description
This pull request introduces a new implementation of a Circular Queue in JavaScript. The Circular Queue is a linear data structure that follows the First In First Out (FIFO) principle and efficiently utilizes memory by wrapping around when the end of the array is reached.
Changes Made
CircularQueue.js
that contains the implementation of the Circular Queue.constructor(capacity)
: Initializes the Circular Queue with a specified capacity.isEmpty()
: Checks if the queue is empty.isFull()
: Checks if the queue is full.peek()
: Reads the element at the front of the queue without removing it.enqueue(value)
: Adds a new element to the end of the queue.dequeue()
: Removes the element at the front of the queue.getSize()
: Returns the current size of the queue.toString()
: Returns the string representation of the queue.Motivation
The motivation behind this addition is to provide an efficient queue implementation that can handle wrap-around cases seamlessly. This is particularly useful for scenarios where memory utilization is crucial and can help in reducing memory overhead compared to a standard queue implementation.
Example Usage
Additional Context