MCPcopy Create free account
hub / github.com/denoland/std / popBack

Method popBack

data_structures/deque.ts:277–285  ·  view source on GitHub ↗

* 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

()

Source from the content-addressed store, hash-verified

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.

Callers 1

deque_test.tsFile · 0.80

Calls 1

#maybeShrinkMethod · 0.95

Tested by

no test coverage detected