MCPcopy Create free account
hub / github.com/FlashpointProject/launcher / set

Method set

src/back/util/map.ts:131–175  ·  view source on GitHub ↗
(key: K, element: V)

Source from the content-addressed store, hash-verified

129 }
130
131 set(key: K, element: V): V | undefined {
132 const iter = this._iter.reset(key);
133 let node: TernarySearchTreeNode<K, V>;
134
135 if (!this._root) {
136 this._root = new TernarySearchTreeNode<K, V>();
137 this._root.segment = iter.value();
138 }
139
140 node = this._root;
141 while (true) {
142 const val = iter.cmp(node.segment);
143 if (val > 0) {
144 // left
145 if (!node.left) {
146 node.left = new TernarySearchTreeNode<K, V>();
147 node.left.segment = iter.value();
148 }
149 node = node.left;
150
151 } else if (val < 0) {
152 // right
153 if (!node.right) {
154 node.right = new TernarySearchTreeNode<K, V>();
155 node.right.segment = iter.value();
156 }
157 node = node.right;
158
159 } else if (iter.hasNext()) {
160 // mid
161 iter.next();
162 if (!node.mid) {
163 node.mid = new TernarySearchTreeNode<K, V>();
164 node.mid.segment = iter.value();
165 }
166 node = node.mid;
167 } else {
168 break;
169 }
170 }
171 const oldElement = node.value;
172 node.value = element;
173 node.key = key;
174 return oldElement;
175 }
176
177 get(key: K): V | undefined {
178 const iter = this._iter.reset(key);

Callers 13

prepForInitFunction · 0.80
initializeFunction · 0.80
lookupFunction · 0.80
newThemeWatcherFunction · 0.80
registerInterceptorFunction · 0.80
loadMethod · 0.80
getExtensionPathIndexMethod · 0.80
createApiFactoryFunction · 0.80
scanSystemExtensionsFunction · 0.80
scanExtensionsFunction · 0.80
FileServerClass · 0.80

Calls 5

resetMethod · 0.65
valueMethod · 0.65
cmpMethod · 0.65
hasNextMethod · 0.65
nextMethod · 0.65

Tested by

no test coverage detected