diff --git a/src/libstd/sort.rs b/src/libstd/sort.rs index f1abe5be5a5..20a18b88320 100644 --- a/src/libstd/sort.rs +++ b/src/libstd/sort.rs @@ -5,12 +5,6 @@ use vec::{len, push}; use core::cmp::{Eq, Ord}; -export le; -export merge_sort; -export quick_sort; -export quick_sort3; -export Sort; - type Le = pure fn(v1: &T, v2: &T) -> bool; /** @@ -19,7 +13,7 @@ type Le = pure fn(v1: &T, v2: &T) -> bool; * 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] { +pub fn merge_sort(le: Le, v: &[const T]) -> ~[T] { type Slice = (uint, uint); return merge_sort_(le, v, (0u, len(v))); @@ -93,7 +87,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]) { +pub fn quick_sort(compare_func: Le, arr: &[mut T]) { if len::(arr) == 0u { return; } qsort::(compare_func, arr, 0u, len::(arr) - 1u); } @@ -155,12 +149,12 @@ fn qsort3(arr: &[mut T], left: int, right: int) { * * This is an unstable sort. */ -fn quick_sort3(arr: &[mut T]) { +pub fn quick_sort3(arr: &[mut T]) { if arr.len() <= 1 { return; } qsort3(arr, 0, (arr.len() - 1) as int); } -trait Sort { +pub trait Sort { fn qsort(self); } @@ -274,7 +268,7 @@ mod tests { fn check_sort(v1: &[int], v2: &[int]) { let len = vec::len::(v1); - pure fn le(a: &int, b: &int) -> bool { *a <= *b } + pub pure fn le(a: &int, b: &int) -> bool { *a <= *b } let f = le; let v3 = merge_sort::(f, v1); let mut i = 0u; @@ -304,7 +298,7 @@ mod tests { #[test] fn test_merge_sort_mutable() { - pure fn le(a: &int, b: &int) -> bool { *a <= *b } + pub pure fn le(a: &int, b: &int) -> bool { *a <= *b } let v1 = ~[mut 3, 2, 1]; let v2 = merge_sort(le, v1); assert v2 == ~[1, 2, 3]; diff --git a/src/libstd/std.rc b/src/libstd/std.rc index fba3f85ae5d..96d7b8c20fc 100644 --- a/src/libstd/std.rc +++ b/src/libstd/std.rc @@ -98,11 +98,8 @@ mod map; mod rope; #[legacy_exports] mod smallintmap; -#[legacy_exports] mod sort; -#[legacy_exports] mod treemap; -#[legacy_exports] // And ... other stuff diff --git a/src/libstd/treemap.rs b/src/libstd/treemap.rs index 7fe8b145ed7..3419f1cb90c 100644 --- a/src/libstd/treemap.rs +++ b/src/libstd/treemap.rs @@ -12,12 +12,7 @@ use core::cmp::{Eq, Ord}; use core::option::{Some, None}; use Option = core::Option; -export TreeMap; -export insert; -export find; -export traverse; - -type TreeMap = @mut TreeEdge; +pub type TreeMap = @mut TreeEdge; type TreeEdge = Option<@TreeNode>; @@ -29,10 +24,10 @@ enum TreeNode = { }; /// Create a treemap -fn TreeMap() -> TreeMap { @mut None } +pub fn TreeMap() -> TreeMap { @mut None } /// Insert a value into the map -fn insert(m: &mut TreeEdge, +k: K, +v: V) { +pub fn insert(m: &mut TreeEdge, +k: K, +v: V) { match copy *m { None => { *m = Some(@TreeNode({key: k, @@ -54,7 +49,7 @@ fn insert(m: &mut TreeEdge, +k: K, +v: V) { } /// Find a value based on the key -fn find(m: &const TreeEdge, +k: K) +pub fn find(m: &const TreeEdge, +k: K) -> Option { match copy *m { None => None, @@ -73,7 +68,7 @@ fn find(m: &const TreeEdge, +k: K) } /// Visit all pairs in the map in order. -fn traverse(m: &const TreeEdge, f: fn((&K), (&V))) { +pub fn traverse(m: &const TreeEdge, f: fn((&K), (&V))) { match copy *m { None => (), Some(node) => {