mirror of
https://github.com/TheAlgorithms/JavaScript.git
synced 2025-07-06 01:18:23 +08:00
Update CircularQueue.js for zero-length case (#1655)
* Update CircularQueue.js * Update CircularQueue.js Taking comments into account for refactoring my change. * Update CircularQueue.js Adding "this" to checkEmpty()
This commit is contained in:
@ -77,7 +77,7 @@ class CircularQueue {
|
|||||||
|
|
||||||
// Displays the length of queue
|
// Displays the length of queue
|
||||||
length() {
|
length() {
|
||||||
return this.queue.length - 1
|
return this.checkEmpty() ? 0 : this.queue.length - 1
|
||||||
}
|
}
|
||||||
|
|
||||||
// Display the top most value of queue
|
// Display the top most value of queue
|
||||||
|
Reference in New Issue
Block a user