Conversation
- Avoid UB in `extract` on single-element heap. - Use correct index arithmetic for parent and children nodes in `_heapify_up` and `_heapify_down`.
| .flag(); | ||
| program.add_argument("-ds", "--dlsym-log") | ||
| .help("path to file containing dlsym log of loaded symbols"); | ||
| program.add_argument("-o", "--output") |
There was a problem hiding this comment.
Why was this argument removed? Fairly certain it is still used.
There was a problem hiding this comment.
It's still there. This removed the second redundant call to add_argument for the --output argument.
| void _heapify_down(size_t i) { | ||
| size_t left_i = 2 * i; | ||
| size_t right_i = 2 * i + 1; | ||
| size_t left_i = 2 * i + 1; |
There was a problem hiding this comment.
Add a comment here to explain the indexing structure? I'm fond of ascii art so a graph like this makes sense to me, but choose what you feel is best.
0
1 2
3 4 5 6
Is it supposed to be index i is at i and its children are at 2i +1, 2i+2? I guess this is the result of 0-indexing instead of 1-indexing as the old version would have worked before.
There was a problem hiding this comment.
Added to the top of the file. Honestly, I would rather avoid using a custom binary heap implementation. I just threw this in because I had it lying around.
|
For future-us reference, might want to just replace this implementation with https://en.cppreference.com/w/cpp/algorithm/make_heap.html |
extracton single-element heap._heapify_upand_heapify_down.