File tree 2 files changed +4
-8
lines changed
2 files changed +4
-8
lines changed Original file line number Diff line number Diff line change @@ -97,12 +97,11 @@ module.exports = class PriorityQueue {
97
97
}
98
98
99
99
removeAt ( pos ) {
100
- if ( pos > this . #size) return ;
101
-
102
100
const heap = this . #heap;
103
- const size = -- this . #size;
104
- heap [ pos ] = heap [ size + 1 ] ;
105
- heap [ size + 1 ] = undefined ;
101
+ let size = this . #size;
102
+ heap [ pos ] = heap [ size ] ;
103
+ heap [ size ] = undefined ;
104
+ size = -- this . #size;
106
105
107
106
if ( size > 0 && pos <= size ) {
108
107
if ( pos > 1 && this . #compare( heap [ pos >> 1 ] , heap [ pos ] ) > 0 )
Original file line number Diff line number Diff line change @@ -102,9 +102,6 @@ const PriorityQueue = require('internal/priority_queue');
102
102
// Check that removing the last item doesn't throw
103
103
queue . removeAt ( 6 ) ;
104
104
105
- // Check that removing an item that doesn't exist doesn't throw
106
- queue . removeAt ( 15 ) ;
107
-
108
105
assert . strictEqual ( queue . shift ( ) . value , 1 ) ;
109
106
assert . strictEqual ( queue . shift ( ) . value , 2 ) ;
110
107
assert . strictEqual ( queue . shift ( ) . value , 2 ) ;
You can’t perform that action at this time.
0 commit comments