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

Method insert

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

437 * @returns `true` if the value was inserted, `false` if the value already exists in the tree.
438 */
439 insert(value: T): boolean {
440 return !!this.#insertNode(BinarySearchNode, value);
441 }
442
443 /**
444 * 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