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

Method remove

data_structures/binary_search_tree.ts:463–467  ·  view source on GitHub ↗

* Remove a value from the binary search tree if it exists in the tree. * * The complexity of this operation is on average O(log n), where n is the * number of values in the tree. In the worst case, the complexity is O(n). * * @example Removing values from the tree * ```ts * impo

(value: T)

Source from the content-addressed store, hash-verified

461 * @returns `true` if the value was found and removed, `false` if the value was not found in the tree.
462 */
463 remove(value: T): boolean {
464 const node: BinarySearchNode<T> | null = this.#findNode(value);
465 if (node) this.#removeNode(node);
466 return node !== null;
467 }
468
469 /**
470 * Check if a value exists in the binary search tree.

Callers

nothing calls this directly

Calls 2

#findNodeMethod · 0.95
#removeNodeMethod · 0.95

Tested by

no test coverage detected