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

Method insert

data_structures/binary_search_tree.ts:437–439  ·  view source on GitHub ↗

* Add a value to the binary search tree if it does not already exist 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 Inserting values into the tree

(value: T)

Source from the content-addressed store, hash-verified

435 * @returns `true` if the value was inserted, `false` if the value already exists in the tree.
436 */
437 insert(value: T): boolean {
438 return !!this.#insertNode(BinarySearchNode, value);
439 }
440
441 /**
442 * Remove a value from the binary search tree if it exists in the tree.

Callers 1

fromMethod · 0.45

Calls 1

#insertNodeMethod · 0.95

Tested by

no test coverage detected