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

Method findSubstr

src/back/util/map.ts:240–262  ·  view source on GitHub ↗
(key: K)

Source from the content-addressed store, hash-verified

238 }
239
240 findSubstr(key: K): V | undefined {
241 const iter = this._iter.reset(key);
242 let node = this._root;
243 let candidate: V | undefined = undefined;
244 while (node) {
245 const val = iter.cmp(node.segment);
246 if (val > 0) {
247 // left
248 node = node.left;
249 } else if (val < 0) {
250 // right
251 node = node.right;
252 } else if (iter.hasNext()) {
253 // mid
254 iter.next();
255 candidate = node.value || candidate;
256 node = node.mid;
257 } else {
258 break;
259 }
260 }
261 return node && node.value || candidate;
262 }
263
264 findSuperstr(key: K): Iterator<V> | undefined {
265 const iter = this._iter.reset(key);

Callers 1

loadMethod · 0.80

Calls 4

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

Tested by

no test coverage detected