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

Method enqueue

Data-Structures/Queue/Queue.js:29–41  ·  view source on GitHub ↗

* @description - Add a value to the end of the queue * @param {*} data * @returns {number} - The current size of queue

(data)

Source from the content-addressed store, hash-verified

27 * @returns {number} - The current size of queue
28 */
29 enqueue(data) {
30 const node = { data, next: null }
31
32 if (!this.head && !this.tail) {
33 this.head = node
34 this.tail = node
35 } else {
36 this.tail.next = node
37 this.tail = node
38 }
39
40 return ++this.#size
41 }
42
43 /**
44 * @description - Removes the value at the front of the queue

Callers 4

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

Calls

no outgoing calls

Tested by

no test coverage detected