digitalmars.D.announce - XSort - Sorting algorithms (including Timsort!)
- Xinok (7/7) Apr 11 2012 I just wanted to share this. I started a project a few weeks ago
- Nathan M. Swan (5/12) Apr 11 2012 Cool! To make it a bit more generic, may I suggest making all the
- Xinok (15/29) Apr 12 2012 This incurs different behavior as random-access ranges would be
- Dmitry Olshansky (5/34) Apr 12 2012 Indeed and there is a standard function array(...) that does this very
I just wanted to share this. I started a project a few weeks ago on Github to implement several sorting algorithms in D. In total, there are 8 modules at the moment, each implementing a sorting algorithm or combination thereof. https://github.com/Xinok/XSort I just finished Timsort today. It's working, it's stable, but I need to spend a little more time better optimizing it.
Apr 11 2012
On Thursday, 12 April 2012 at 03:04:49 UTC, Xinok wrote:I just wanted to share this. I started a project a few weeks ago on Github to implement several sorting algorithms in D. In total, there are 8 modules at the moment, each implementing a sorting algorithm or combination thereof. https://github.com/Xinok/XSort I just finished Timsort today. It's working, it's stable, but I need to spend a little more time better optimizing it.Cool! To make it a bit more generic, may I suggest making all the inputs only have to be "isInputRange", and have it converted to an array. NMS
Apr 11 2012
On Thursday, 12 April 2012 at 05:25:52 UTC, Nathan M. Swan wrote:On Thursday, 12 April 2012 at 03:04:49 UTC, Xinok wrote:This incurs different behavior as random-access ranges would be sorted in place and input ranges wouldn't be. I could add separate functions to make this behavior explicit, but I see little point in doing so. It's quite easy to convert an input range to an array yourself: import std.array, std.range; auto inputRangeToArray(R)(R range) if(isInputRange!R && !isInfinite!R) { auto app = Appender!(ElementType!(R)[])(); static if(hasLength!R) app.reserve(range.length); app.put(range); return app.data; }I just wanted to share this. I started a project a few weeks ago on Github to implement several sorting algorithms in D. In total, there are 8 modules at the moment, each implementing a sorting algorithm or combination thereof. https://github.com/Xinok/XSort I just finished Timsort today. It's working, it's stable, but I need to spend a little more time better optimizing it.Cool! To make it a bit more generic, may I suggest making all the inputs only have to be "isInputRange", and have it converted to an array. NMS
Apr 12 2012
On 12.04.2012 18:50, Xinok wrote:On Thursday, 12 April 2012 at 05:25:52 UTC, Nathan M. Swan wrote:Indeed and there is a standard function array(...) that does this very thing. -- Dmitry OlshanskyOn Thursday, 12 April 2012 at 03:04:49 UTC, Xinok wrote:This incurs different behavior as random-access ranges would be sorted in place and input ranges wouldn't be. I could add separate functions to make this behavior explicit, but I see little point in doing so. It's quite easy to convert an input range to an array yourself: import std.array, std.range; auto inputRangeToArray(R)(R range) if(isInputRange!R && !isInfinite!R) { auto app = Appender!(ElementType!(R)[])(); static if(hasLength!R) app.reserve(range.length); app.put(range); return app.data; }I just wanted to share this. I started a project a few weeks ago on Github to implement several sorting algorithms in D. In total, there are 8 modules at the moment, each implementing a sorting algorithm or combination thereof. https://github.com/Xinok/XSort I just finished Timsort today. It's working, it's stable, but I need to spend a little more time better optimizing it.Cool! To make it a bit more generic, may I suggest making all the inputs only have to be "isInputRange", and have it converted to an array. NMS
Apr 12 2012