From 8182497359237cf2d842bc614eae2bf24bc2517a Mon Sep 17 00:00:00 2001 From: Brian Anderson Date: Tue, 4 Sep 2012 14:37:47 -0700 Subject: [PATCH] std: Camel case sort --- src/libstd/sort.rs | 16 ++++++++-------- src/libstd/std.rc | 1 - 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/libstd/sort.rs b/src/libstd/sort.rs index fc5ffa3384c..4c10e274d49 100644 --- a/src/libstd/sort.rs +++ b/src/libstd/sort.rs @@ -11,7 +11,7 @@ export quick_sort3; export Sort; -type le = pure fn(v1: &T, v2: &T) -> bool; +type Le = pure fn(v1: &T, v2: &T) -> bool; /** * Merge sort. Returns a new vector containing the sorted list. @@ -19,12 +19,12 @@ * 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(le: le, v: &[const T]) -> ~[T] { - type slice = (uint, uint); +fn merge_sort(le: Le, v: &[const T]) -> ~[T] { + type Slice = (uint, uint); return merge_sort_(le, v, (0u, len(v))); - fn merge_sort_(le: le, v: &[const T], slice: slice) + fn merge_sort_(le: Le, v: &[const T], slice: Slice) -> ~[T] { let begin = slice.first(); let end = slice.second(); @@ -39,7 +39,7 @@ fn merge_sort_(le: le, v: &[const T], slice: slice) return merge(le, merge_sort_(le, v, a), merge_sort_(le, v, b)); } - fn merge(le: le, a: &[T], b: &[T]) -> ~[T] { + fn merge(le: Le, a: &[T], b: &[T]) -> ~[T] { let mut rs = ~[]; vec::reserve(rs, len(a) + len(b)); let a_len = len(a); @@ -58,7 +58,7 @@ fn merge(le: le, a: &[T], b: &[T]) -> ~[T] { } } -fn part(compare_func: le, arr: &[mut T], left: uint, +fn part(compare_func: Le, arr: &[mut T], left: uint, right: uint, pivot: uint) -> uint { let pivot_value = arr[pivot]; arr[pivot] <-> arr[right]; @@ -75,7 +75,7 @@ fn part(compare_func: le, arr: &[mut T], left: uint, return storage_index; } -fn qsort(compare_func: le, arr: &[mut T], left: uint, +fn qsort(compare_func: Le, arr: &[mut T], left: uint, right: uint) { if right > left { let pivot = (left + right) / 2u; @@ -94,7 +94,7 @@ fn qsort(compare_func: le, arr: &[mut T], left: uint, * Has worst case O(n^2) performance, average case O(n log n). * This is an unstable sort. */ -fn quick_sort(compare_func: le, arr: &[mut T]) { +fn quick_sort(compare_func: Le, arr: &[mut T]) { if len::(arr) == 0u { return; } qsort::(compare_func, arr, 0u, len::(arr) - 1u); } diff --git a/src/libstd/std.rc b/src/libstd/std.rc index da96e871beb..dbc56d3f5e3 100644 --- a/src/libstd/std.rc +++ b/src/libstd/std.rc @@ -67,7 +67,6 @@ mod map; mod rope; #[allow(non_camel_case_types)] // XXX mod smallintmap; -#[allow(non_camel_case_types)] // XXX mod sort; mod treemap;