File tree 1 file changed +3
-4
lines changed
1 file changed +3
-4
lines changed Original file line number Diff line number Diff line change @@ -3,8 +3,7 @@ Minimum Priority Queue implementation using heap.
3
3
4
4
elementHeap stores all element,
5
5
priorityHeap stores priority for given element,
6
- priority[i] stores priority of element[i].
7
-
6
+ priorityHeap[i] stores priority of elementHeap[i].
8
7
indexLookup stores index of element, so when priority is changed,
9
8
the top or bottom heap can be fixed from that position itself.
10
9
*/
@@ -48,7 +47,7 @@ class PriorityQueue {
48
47
}
49
48
50
49
/*
51
- To fix bootom heap from position: idx
50
+ To fix bottom heap from position: idx
52
51
53
52
Finds if left or right child is smaller, if true, swaps smallest element
54
53
with parent and then calls fixBottomHeap for index of smallest element
@@ -123,7 +122,7 @@ class PriorityQueue {
123
122
this . _swap ( 0 , this . _size - 1 ) ;
124
123
this . _elementHeap . splice ( - 1 , 1 ) ;
125
124
this . _priorityHeap . splice ( - 1 , 1 ) ;
126
- this . _indexLookup [ _minPriorityItem ] = null ;
125
+ delete this . _indexLookup [ _minPriorityItem ] ;
127
126
this . _size -- ;
128
127
129
128
this . _fixBottomHeap ( 0 ) ;
You can’t perform that action at this time.
0 commit comments