MCPcopy Index your code
hub / github.com/TheAlgorithms/JavaScript / dequeue

Method dequeue

Data-Structures/Queue/Queue.js:47–63  ·  view source on GitHub ↗

* @description - Removes the value at the front of the queue * @returns {*} - The first data of the queue

()

Source from the content-addressed store, hash-verified

45 * @returns {*} - The first data of the queue
46 */
47 dequeue() {
48 if (this.isEmpty()) {
49 throw new Error('Queue is Empty')
50 }
51
52 const firstData = this.peekFirst()
53
54 this.head = this.head.next
55
56 if (!this.head) {
57 this.tail = null
58 }
59
60 this.#size--
61
62 return firstData
63 }
64
65 /**
66 * @description - Return the item at the front of the queue

Callers 4

breadthFirstSearchFunction · 0.95
breadthFirstShortestPathFunction · 0.95
Queue.test.jsFile · 0.45

Calls 2

isEmptyMethod · 0.95
peekFirstMethod · 0.95

Tested by

no test coverage detected