* Remove and return the back element, or `undefined` if the deque is empty. * * @example Popping from the back * ```ts * import { Deque } from "@std/data-structures/deque"; * import { assertEquals } from "@std/assert"; * * const deque = new Deque([1, 2, 3]); * assertEquals(de
()
| 275 | * @returns The back element, or `undefined` if empty. |
| 276 | */ |
| 277 | popBack(): T | undefined { |
| 278 | if (this.#length === 0) return undefined; |
| 279 | this.#length--; |
| 280 | const index = (this.#head + this.#length) & this.#mask; |
| 281 | const value = this.#buffer[index]; |
| 282 | this.#buffer[index] = undefined; |
| 283 | this.#maybeShrink(); |
| 284 | return value; |
| 285 | } |
| 286 | |
| 287 | /** |
| 288 | * Remove and return the front element, or `undefined` if the deque is empty. |
no test coverage detected