| ... | ... | @@ -109,6 +109,7 @@ test "binarySearch" { |
| 109 | 109 | |
| 110 | 110 | /// Stable in-place sort. O(n) best case, O(pow(n, 2)) worst case. |
| 111 | 111 | /// O(1) memory (no allocator required). |
| 112 | /// Sorts in ascending order with respect to the given `lessThan` function. |
| 112 | 113 | /// This can be expressed in terms of `insertionSortContext` but the glue |
| 113 | 114 | /// code is slightly longer than the direct implementation. |
| 114 | 115 | pub fn insertionSort( |
| ... | ... | @@ -130,6 +131,7 @@ pub fn insertionSort( |
| 130 | 131 | |
| 131 | 132 | /// Stable in-place sort. O(n) best case, O(pow(n, 2)) worst case. |
| 132 | 133 | /// O(1) memory (no allocator required). |
| 134 | /// Sorts in ascending order with respect to the given `context.lessThan` function. |
| 133 | 135 | pub fn insertionSortContext(len: usize, context: anytype) void { |
| 134 | 136 | var i: usize = 1; |
| 135 | 137 | while (i < len) : (i += 1) { |
| ... | ... | @@ -229,6 +231,7 @@ const Pull = struct { |
| 229 | 231 | |
| 230 | 232 | /// Stable in-place sort. O(n) best case, O(n*log(n)) worst case and average case. |
| 231 | 233 | /// O(1) memory (no allocator required). |
| 234 | /// Sorts in ascending order with respect to the given `lessThan` function. |
| 232 | 235 | /// Currently implemented as block sort. |
| 233 | 236 | pub fn sort( |
| 234 | 237 | comptime T: type, |