File tree Expand file tree Collapse file tree 1 file changed +10
-10
lines changed Expand file tree Collapse file tree 1 file changed +10
-10
lines changed Original file line number Diff line number Diff line change @@ -51,22 +51,22 @@ module.exports = class PriorityQueue {
5151 const item = heap [ pos ] ;
5252
5353 while ( pos <= hsize ) {
54- let left = pos << 1 ;
55- const right = left + 1 ;
56- let child = heap [ left ] ;
54+ let child = pos << 1 ;
55+ const nextChild = child + 1 ;
56+ let childItem = heap [ child ] ;
5757
58- if ( right <= size && compare ( heap [ right ] , child ) < 0 ) {
59- left = right ;
60- child = heap [ right ] ;
58+ if ( nextChild <= size && compare ( heap [ nextChild ] , childItem ) < 0 ) {
59+ child = nextChild ;
60+ childItem = heap [ nextChild ] ;
6161 }
6262
63- if ( compare ( item , child ) <= 0 ) break ;
63+ if ( compare ( item , childItem ) <= 0 ) break ;
6464
6565 if ( setPosition !== undefined )
66- setPosition ( child , pos ) ;
66+ setPosition ( childItem , pos ) ;
6767
68- heap [ pos ] = child ;
69- pos = left ;
68+ heap [ pos ] = childItem ;
69+ pos = child ;
7070 }
7171
7272 heap [ pos ] = item ;
You can’t perform that action at this time.
0 commit comments