MCPcopy Create free account
hub / github.com/microsoft/SandDance / siftUp

Function siftUp

docs/external/js/react.development.js:2269–2286  ·  view source on GitHub ↗
(heap, node, i)

Source from the content-addressed store, hash-verified

2267 }
2268
2269 function siftUp(heap, node, i) {
2270 var index = i;
2271
2272 while (true) {
2273 var parentIndex = index - 1 >>> 1;
2274 var parent = heap[parentIndex];
2275
2276 if (parent !== undefined && compare(parent, node) > 0) {
2277 // The parent is larger. Swap positions.
2278 heap[parentIndex] = node;
2279 heap[index] = parent;
2280 index = parentIndex;
2281 } else {
2282 // The parent is smaller. Exit.
2283 return;
2284 }
2285 }
2286 }
2287
2288 function siftDown(heap, node, i) {
2289 var index = i;

Callers 1

pushFunction · 0.85

Calls 1

compareFunction · 0.70

Tested by

no test coverage detected