| 108674 | }; |
| 108675 | } |
| 108676 | function 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 | } |
| 108691 | function siftup(array, idx, cmp) { |
| 108692 | const start = idx, end = array.length, item = array[idx]; |
| 108693 | let cidx = (idx << 1) + 1, ridx; |