about summary refs log tree commit diff
path: root/src/libstd/par.rs
diff options
context:
space:
mode:
authorSimon BD <simon@server>2012-10-03 21:47:09 -0500
committerSimon BD <simon@server>2012-10-03 21:47:09 -0500
commitefcd2385ea2389f270ff8ac8bc256636f647b130 (patch)
tree7e142ef709bc907a34ab1cb252eef6dcc0e83b91 /src/libstd/par.rs
parent44f8a4401ab37a45ba49db56611d77807bcbce35 (diff)
parent3ccf6f5932d8223fd6c5cbf7c6ac429ca9e8912a (diff)
Merge remote-tracking branch 'original/incoming' into incoming
Conflicts:
	src/libstd/json.rs
	src/libstd/sort.rs
Diffstat (limited to 'src/libstd/par.rs')
-rw-r--r--src/libstd/par.rs23
1 files changed, 11 insertions, 12 deletions
diff --git a/src/libstd/par.rs b/src/libstd/par.rs
index 38a814b22e0..65e41dba5d8 100644
--- a/src/libstd/par.rs
+++ b/src/libstd/par.rs
@@ -1,6 +1,5 @@
 use future_spawn = future::spawn;
 
-export map, mapi, alli, any, mapi_factory;
 
 /**
  * The maximum number of tasks this module will spawn for a single
@@ -55,7 +54,7 @@ fn map_slices<A: Copy Send, B: Copy Send>(
                         f(base, slice)
                     }
                 };
-                vec::push(futures, move f);
+                futures.push(move f);
             };
             base += items_per_task;
         }
@@ -73,21 +72,21 @@ fn map_slices<A: Copy Send, B: Copy Send>(
 }
 
 /// A parallel version of map.
-fn map<A: Copy Send, B: Copy Send>(xs: ~[A], f: fn~(A) -> B) -> ~[B] {
+pub fn map<A: Copy Send, B: Copy Send>(xs: &[A], +f: fn~((&A)) -> B) -> ~[B] {
     vec::concat(map_slices(xs, || {
         fn~(_base: uint, slice : &[A], copy f) -> ~[B] {
-            vec::map(slice, |x| f(*x))
+            vec::map(slice, |x| f(x))
         }
     }))
 }
 
 /// A parallel version of mapi.
-fn mapi<A: Copy Send, B: Copy Send>(xs: ~[A],
-                                    f: fn~(uint, A) -> B) -> ~[B] {
+pub fn mapi<A: Copy Send, B: Copy Send>(xs: &[A],
+                                    +f: fn~(uint, (&A)) -> B) -> ~[B] {
     let slices = map_slices(xs, || {
         fn~(base: uint, slice : &[A], copy f) -> ~[B] {
             vec::mapi(slice, |i, x| {
-                f(i + base, *x)
+                f(i + base, x)
             })
         }
     });
@@ -103,7 +102,7 @@ fn mapi<A: Copy Send, B: Copy Send>(xs: ~[A],
  * In this case, f is a function that creates functions to run over the
  * inner elements. This is to skirt the need for copy constructors.
  */
-fn mapi_factory<A: Copy Send, B: Copy Send>(
+pub fn mapi_factory<A: Copy Send, B: Copy Send>(
     xs: &[A], f: fn() -> fn~(uint, A) -> B) -> ~[B] {
     let slices = map_slices(xs, || {
         let f = f();
@@ -120,21 +119,21 @@ fn mapi_factory<A: Copy Send, B: Copy Send>(
 }
 
 /// Returns true if the function holds for all elements in the vector.
-fn alli<A: Copy Send>(xs: ~[A], f: fn~(uint, A) -> bool) -> bool {
+pub fn alli<A: Copy Send>(xs: &[A], +f: fn~(uint, (&A)) -> bool) -> bool {
     do vec::all(map_slices(xs, || {
         fn~(base: uint, slice : &[A], copy f) -> bool {
             vec::alli(slice, |i, x| {
                 f(i + base, x)
             })
         }
-    })) |x| { x }
+    })) |x| { *x }
 }
 
 /// Returns true if the function holds for any elements in the vector.
-fn any<A: Copy Send>(xs: ~[A], f: fn~(A) -> bool) -> bool {
+pub fn any<A: Copy Send>(xs: &[A], +f: fn~(&(A)) -> bool) -> bool {
     do vec::any(map_slices(xs, || {
         fn~(_base : uint, slice: &[A], copy f) -> bool {
             vec::any(slice, |x| f(x))
         }
-    })) |x| { x }
+    })) |x| { *x }
 }