diff options
Diffstat (limited to 'src/libstd/sort.rs')
| -rw-r--r-- | src/libstd/sort.rs | 46 |
1 files changed, 23 insertions, 23 deletions
diff --git a/src/libstd/sort.rs b/src/libstd/sort.rs index 7de8f0cfab8..d0092e97cb3 100644 --- a/src/libstd/sort.rs +++ b/src/libstd/sort.rs @@ -1,4 +1,4 @@ -#[doc = "Sorting methods"]; +//! Sorting methods import vec::{len, push}; import int::{eq, ord}; @@ -9,12 +9,12 @@ export quick_sort3; type le<T> = fn(T, T) -> bool; -#[doc = " -Merge sort. Returns a new vector containing the sorted list. - -Has worst case O(n log n) performance, best case O(n), but -is not space efficient. This is a stable sort. -"] +/** + * Merge sort. Returns a new vector containing the sorted list. + * + * Has worst case O(n log n) performance, best case O(n), but + * is not space efficient. This is a stable sort. + */ fn merge_sort<T: copy>(le: le<T>, v: ~[const T]) -> ~[T] { type slice = (uint, uint); @@ -84,12 +84,12 @@ fn qsort<T: copy>(compare_func: le<T>, arr: ~[mut T], left: uint, } } -#[doc = " -Quicksort. Sorts a mut vector in place. - -Has worst case O(n^2) performance, average case O(n log n). -This is an unstable sort. -"] +/** + * Quicksort. Sorts a mut vector in place. + * + * Has worst case O(n^2) performance, average case O(n log n). + * This is an unstable sort. + */ fn quick_sort<T: copy>(compare_func: le<T>, arr: ~[mut T]) { if len::<T>(arr) == 0u { ret; } qsort::<T>(compare_func, arr, 0u, len::<T>(arr) - 1u); @@ -143,16 +143,16 @@ fn qsort3<T: copy>(compare_func_lt: le<T>, compare_func_eq: le<T>, qsort3::<T>(compare_func_lt, compare_func_eq, arr, i, right); } -#[doc = " -Fancy quicksort. Sorts a mut vector in place. - -Based on algorithm presented by [Sedgewick and Bentley]/~ -(http://www.cs.princeton.edu/~rs/talks/QuicksortIsOptimal.pdf). -According to these slides this is the algorithm of choice for -'randomly ordered keys, abstract compare' & 'small number of key values'. - -This is an unstable sort. -"] +/** + * Fancy quicksort. Sorts a mut vector in place. + * + * Based on algorithm presented by [Sedgewick and Bentley]/~ + * (http://www.cs.princeton.edu/~rs/talks/QuicksortIsOptimal.pdf). + * According to these slides this is the algorithm of choice for + * 'randomly ordered keys, abstract compare' & 'small number of key values'. + * + * This is an unstable sort. + */ fn quick_sort3<T: copy ord eq>(arr: ~[mut T]) { if len::<T>(arr) == 0u { ret; } qsort3::<T>(|x, y| x.lt(y), |x, y| x.eq(y), arr, 0, |
