* Removes the element at the front of the Queue. * @return {*} The element at the front of the Queue.
()
| 37 | * @return {*} The element at the front of the Queue. |
| 38 | */ |
| 39 | dequeue(): T | undefined { |
| 40 | if (this.isEmpty()) { |
| 41 | return undefined; |
| 42 | } |
| 43 | |
| 44 | const node = this._dummyHead.next as Node<T>; |
| 45 | const newFirst = node.next as Node<T> | DummyTailNode; |
| 46 | this._dummyHead.next = newFirst; |
| 47 | newFirst.prev = this._dummyHead; |
| 48 | node.next = null; |
| 49 | this._length--; |
| 50 | return node.value; |
| 51 | } |
| 52 | |
| 53 | /** |
| 54 | * Returns true if the Queue has no elements. |
no test coverage detected