summaryrefslogtreecommitdiff
path: root/grailsort.c
Commit message (Collapse)AuthorAgeFilesLines
* Optimize buffer stealing stepBobby Bingham2014-11-041-18/+16
| | | | | We can implement this with just a merge step, rather than completely resorting the b subsequence.
* Remove unused parameterBobby Bingham2014-11-041-2/+2
|
* Fill buffer with smallest elementsBobby Bingham2014-11-021-1/+33
| | | | | | This avoids the need to distribute the buffer through the whole array at the end. It also allows us to skips most of the work for sorted and reverse-sorted inputs.
* Switch to a stationary buffer, rather than moving it through the arrayBobby Bingham2014-11-021-37/+35
|
* Perform swaps in larger chunks in merge stepBobby Bingham2014-10-291-11/+20
| | | | | | Provides about a 10% overall speedup for the sorted+noise and reverse+noise test cases. Increases the number of comparisons in some of the other cases, but doesn't significantly change the runtime.
* Add debugging assertionBobby Bingham2014-10-291-0/+4
|
* Add instrumentationBobby Bingham2014-10-291-0/+12
| | | | | Track the number of comparisons, swaps, and rotations performed in each part of the sorting algorithm.
* Rework block merge sort algorithmBobby Bingham2014-10-261-28/+36
| | | | | This was previously broken for certain inputs, particularly two concatenated sorted sequences.
* Fix grailsort block mergingBobby Bingham2014-09-011-28/+28
| | | | | Previously, we did not correctly handle some cases where a block contained elements with a uniform value.
* Use binary search in mergeBobby Bingham2014-08-231-4/+3
|
* Slightly simplify grailsortBobby Bingham2014-08-161-7/+8
| | | | | Remove unused pending variable, and unused return value from merge(). Saves 29 bytes on x86_64.
* Remove unnecessary test of bnmelBobby Bingham2014-08-031-1/+1
|
* ReformatBobby Bingham2014-07-311-10/+3
|
* Remove grailsort dependency on bsearchBobby Bingham2014-07-311-3/+3
|
* Don't pre-sort the temp swap bufferBobby Bingham2014-07-311-4/+5
| | | | | | | | | This is a close call. On the one hand, this buffer will get jumbled when used for merging adjacent blocks, so we'll need to sort it again before distributing it. On the other hand, by sorting it early, we know that we won't have to distribute it very far. In testing, pre-sorting seems to lose out overall.
* Don't special-case reverse sort orderBobby Bingham2014-07-311-6/+0
| | | | This increases code size, and doesn't seem to help very significantly.
* Move wikisort/grailsort common code to a shared headerBobby Bingham2014-07-061-109/+8
|
* Add an implementation of grailsortBobby Bingham2014-07-061-0/+192