File tree 1 file changed +10
-10
lines changed
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 {
51
51
const item = heap [ pos ] ;
52
52
53
53
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 ] ;
57
57
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 ] ;
61
61
}
62
62
63
- if ( compare ( item , child ) <= 0 ) break ;
63
+ if ( compare ( item , childItem ) <= 0 ) break ;
64
64
65
65
if ( setPosition !== undefined )
66
- setPosition ( child , pos ) ;
66
+ setPosition ( childItem , pos ) ;
67
67
68
- heap [ pos ] = child ;
69
- pos = left ;
68
+ heap [ pos ] = childItem ;
69
+ pos = child ;
70
70
}
71
71
72
72
heap [ pos ] = item ;
You can’t perform that action at this time.
0 commit comments