* Remove and return the front element, or `undefined` if the deque is empty. * * @example Popping from the front * ```ts * import { Deque } from "@std/data-structures/deque"; * import { assertEquals } from "@std/assert"; * * const deque = new Deque([1, 2, 3]); * assertEquals(
()
| 300 | * @returns The front element, or `undefined` if empty. |
| 301 | */ |
| 302 | popFront(): T | undefined { |
| 303 | if (this.#length === 0) return undefined; |
| 304 | const value = this.#buffer[this.#head]; |
| 305 | this.#buffer[this.#head] = undefined; |
| 306 | this.#head = (this.#head + 1) & this.#mask; |
| 307 | this.#length--; |
| 308 | this.#maybeShrink(); |
| 309 | return value; |
| 310 | } |
| 311 | |
| 312 | /** |
| 313 | * Remove and return the first element matching the predicate, scanning from |
no test coverage detected