Skip to content

Commit

Permalink
CHG: [C++] Increase reserved heap-size for element swapping
Browse files Browse the repository at this point in the history
  • Loading branch information
RUrlus committed May 27, 2024
1 parent 924e6f9 commit d4fccfc
Showing 1 changed file with 1 addition and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class MaxHeap {
* \param initial initial `val` to set for all the entries
*/
explicit MaxHeap(int n, eT initial) : heap_size{n}, init{initial} {
heap.reserve(n);
heap.reserve(n + 1);
for (int i = 0; i < heap_size; i++) {
heap.push_back({max_order, -1, initial});
}
Expand Down

0 comments on commit d4fccfc

Please sign in to comment.