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

Function siftdown

docs/app/js/sanddance-app.js:108676–108690  ·  view source on GitHub ↗
(array, start, idx, cmp)

Source from the content-addressed store, hash-verified

108674 };
108675}
108676function siftdown(array, start, idx, cmp) {
108677 let parent, pidx;
108678 const item = array[idx];
108679 while(idx > start){
108680 pidx = idx - 1 >> 1;
108681 parent = array[pidx];
108682 if (cmp(item, parent) < 0) {
108683 array[idx] = parent;
108684 idx = pidx;
108685 continue;
108686 }
108687 break;
108688 }
108689 return array[idx] = item;
108690}
108691function siftup(array, idx, cmp) {
108692 const start = idx, end = array.length, item = array[idx];
108693 let cidx = (idx << 1) + 1, ridx;

Callers 2

HeapFunction · 0.70
siftupFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected