Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bring merge sort and insertion sort cmp function semantics together
Merge sort uses cmp (a, b) < 0 for its first test branch, and insertion sort cmp (a, b) > 0 ; which means the 0 boundary goes in one case in one branch, and in the other sort function in the other branch. We keep the semantics of the insertion sort, because some code already relies on this, like register sorting and re-indexing in libr/reg/reg.c; it makes it possible to support compare function that return true/false instead of a distance between items. Add a test that was previously failing for merge sort (but working with insertion sort); based on real-world data of a list of registers that went from < 43 elements (insertion sort) to 104 elements (merge sort). The main difference is the test function that sends true/false instead of a difference between two integers. Fix merge sort similarly in shlr/sdb/src/ls which combines both insertion sort and merge sort with the same bugs. Update tests that were broken because of wrong register ordering.
- Loading branch information
Showing
8 changed files
with
222 additions
and
173 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.