MCPcopy Index your code
hub / github.com/nodejs/node / insert

Method insert

deps/v8/tools/splaytree.mjs:63–84  ·  view source on GitHub ↗

* Inserts a node into the tree with the specified key and value if * the tree does not already contain a node with the specified key. If * the value is inserted, it becomes the root of the tree. * * @param {number} key Key to insert into the tree. * @param {*} value Value to insert in

(key, value)

Source from the content-addressed store, hash-verified

61 * @param {*} value Value to insert into the tree.
62 */
63 insert(key, value) {
64 if (this.isEmpty()) {
65 this.root_ = new SplayTreeNode(key, value);
66 return;
67 }
68 // Splay on the key to move the last node on the search path for
69 // the key to the root of the tree.
70 this.splay_(key);
71 if (this.root_.key == key) return;
72
73 const node = new SplayTreeNode(key, value);
74 if (key > this.root_.key) {
75 node.left = this.root_;
76 node.right = this.root_.right;
77 this.root_.right = null;
78 } else {
79 node.right = this.root_;
80 node.left = this.root_.left;
81 this.root_.left = null;
82 }
83 this.root_ = node;
84 }
85
86 /**
87 * Removes a node with the specified key from the tree if the tree

Callers 15

add_depot_tools_to_pathFunction · 0.45
addAnyCodeMethod · 0.45
addCodeMethod · 0.45
moveCodeMethod · 0.45
addLibraryMethod · 0.45
addStaticCodeMethod · 0.45
get_landmines.pyFile · 0.45
copy-prereqs.pyFile · 0.45
_import_gsutilMethod · 0.45
ll_prof.pyFile · 0.45

Calls 2

isEmptyMethod · 0.95
splay_Method · 0.95

Tested by

no test coverage detected