Skip to content

Commit a02f332

Browse files
thomasleemarijnh
authored andcommitted
std: rename sort::lteq to sort::le.
1 parent 43ce383 commit a02f332

File tree

1 file changed

+17
-17
lines changed

1 file changed

+17
-17
lines changed

src/libstd/sort.rs

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ export merge_sort;
99
export quick_sort;
1010
export quick_sort3;
1111

12-
/* Type: lteq */
13-
type lteq<T> = fn(T, T) -> bool;
12+
/* Type: le */
13+
type le<T> = fn(T, T) -> bool;
1414

1515
/*
1616
Function: merge_sort
@@ -20,8 +20,8 @@ Merge sort. Returns a new vector containing the sorted list.
2020
Has worst case O(n log n) performance, best case O(n), but
2121
is not space efficient. This is a stable sort.
2222
*/
23-
fn merge_sort<T: copy>(le: lteq<T>, v: [const T]) -> [T] {
24-
fn merge<T: copy>(le: lteq<T>, a: [T], b: [T]) -> [T] {
23+
fn merge_sort<T: copy>(le: le<T>, v: [const T]) -> [T] {
24+
fn merge<T: copy>(le: le<T>, a: [T], b: [T]) -> [T] {
2525
let rs: [T] = [];
2626
let a_len: uint = len::<T>(a);
2727
let a_ix: uint = 0u;
@@ -46,7 +46,7 @@ fn merge_sort<T: copy>(le: lteq<T>, v: [const T]) -> [T] {
4646
ret merge::<T>(le, merge_sort::<T>(le, a), merge_sort::<T>(le, b));
4747
}
4848

49-
fn part<T: copy>(compare_func: lteq<T>, arr: [mutable T], left: uint,
49+
fn part<T: copy>(compare_func: le<T>, arr: [mutable T], left: uint,
5050
right: uint, pivot: uint) -> uint {
5151
let pivot_value = arr[pivot];
5252
arr[pivot] <-> arr[right];
@@ -63,7 +63,7 @@ fn part<T: copy>(compare_func: lteq<T>, arr: [mutable T], left: uint,
6363
ret storage_index;
6464
}
6565

66-
fn qsort<T: copy>(compare_func: lteq<T>, arr: [mutable T], left: uint,
66+
fn qsort<T: copy>(compare_func: le<T>, arr: [mutable T], left: uint,
6767
right: uint) {
6868
if right > left {
6969
let pivot = (left + right) / 2u;
@@ -84,12 +84,12 @@ Quicksort. Sorts a mutable vector in place.
8484
Has worst case O(n^2) performance, average case O(n log n).
8585
This is an unstable sort.
8686
*/
87-
fn quick_sort<T: copy>(compare_func: lteq<T>, arr: [mutable T]) {
87+
fn quick_sort<T: copy>(compare_func: le<T>, arr: [mutable T]) {
8888
if len::<T>(arr) == 0u { ret; }
8989
qsort::<T>(compare_func, arr, 0u, len::<T>(arr) - 1u);
9090
}
9191

92-
fn qsort3<T: copy>(compare_func_lt: lteq<T>, compare_func_eq: lteq<T>,
92+
fn qsort3<T: copy>(compare_func_lt: le<T>, compare_func_eq: le<T>,
9393
arr: [mutable T], left: int, right: int) {
9494
if right <= left { ret; }
9595
let v: T = arr[right];
@@ -150,7 +150,7 @@ According to these slides this is the algorithm of choice for
150150
151151
This is an unstable sort.
152152
*/
153-
fn quick_sort3<T: copy>(compare_func_lt: lteq<T>, compare_func_eq: lteq<T>,
153+
fn quick_sort3<T: copy>(compare_func_lt: le<T>, compare_func_eq: le<T>,
154154
arr: [mutable T]) {
155155
if len::<T>(arr) == 0u { ret; }
156156
qsort3::<T>(compare_func_lt, compare_func_eq, arr, 0,
@@ -204,8 +204,8 @@ mod test_qsort3 {
204204
mod test_qsort {
205205
fn check_sort(v1: [mutable int], v2: [mutable int]) {
206206
let len = vec::len::<int>(v1);
207-
fn ltequal(&&a: int, &&b: int) -> bool { ret a <= b; }
208-
let f = ltequal;
207+
fn leual(&&a: int, &&b: int) -> bool { ret a <= b; }
208+
let f = leual;
209209
quick_sort::<int>(f, v1);
210210
let i = 0u;
211211
while i < len {
@@ -247,8 +247,8 @@ mod test_qsort {
247247

248248
let expected = [1, 2, 3];
249249

250-
fn lteq(&&a: int, &&b: int) -> bool { int::le(a, b) }
251-
sort::quick_sort(lteq, names);
250+
fn le(&&a: int, &&b: int) -> bool { int::le(a, b) }
251+
sort::quick_sort(le, names);
252252

253253
let immut_names = vec::from_mut(names);
254254

@@ -264,8 +264,8 @@ mod tests {
264264

265265
fn check_sort(v1: [int], v2: [int]) {
266266
let len = vec::len::<int>(v1);
267-
fn lteq(&&a: int, &&b: int) -> bool { ret a <= b; }
268-
let f = lteq;
267+
fn le(&&a: int, &&b: int) -> bool { ret a <= b; }
268+
let f = le;
269269
let v3 = merge_sort::<int>(f, v1);
270270
let i = 0u;
271271
while i < len {
@@ -294,9 +294,9 @@ mod tests {
294294

295295
#[test]
296296
fn test_merge_sort_mutable() {
297-
fn lteq(&&a: int, &&b: int) -> bool { ret a <= b; }
297+
fn le(&&a: int, &&b: int) -> bool { ret a <= b; }
298298
let v1 = [mutable 3, 2, 1];
299-
let v2 = merge_sort(lteq, v1);
299+
let v2 = merge_sort(le, v1);
300300
assert v2 == [1, 2, 3];
301301
}
302302
}

0 commit comments

Comments
 (0)