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

Method remove

data_structures/binary_search_tree.ts:461–465  ·  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

459 * @returns `true` if the value was found and removed, `false` if the value was not found in the tree.
460 */
461 remove(value: T): boolean {
462 const node: BinarySearchNode<T> | null = this.#findNode(value);
463 if (node) this.#removeNode(node);
464 return node !== null;
465 }
466
467 /**
468 * 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