* @description - Add a value to the end of the queue * @param {*} data * @returns {number} - The current size of queue
(data)
| 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 |
no outgoing calls
no test coverage detected