1
1
use future_spawn = future:: spawn;
2
2
3
- export map, mapi, alli, any, mapi_factory;
4
3
5
4
/**
6
5
* The maximum number of tasks this module will spawn for a single
@@ -73,7 +72,7 @@ fn map_slices<A: Copy Send, B: Copy Send>(
73
72
}
74
73
75
74
/// A parallel version of map.
76
- fn map< A : Copy Send , B : Copy Send > ( xs : ~[ A ] , f : fn ~( A ) -> B ) -> ~[ B ] {
75
+ pub fn map< A : Copy Send , B : Copy Send > ( xs : ~[ A ] , f : fn ~( A ) -> B ) -> ~[ B ] {
77
76
vec:: concat( map_slices( xs, || {
78
77
fn ~( _base: uint, slice : & [ A ] , copy f) -> ~[ B ] {
79
78
vec:: map( slice , |x| f( * x) )
@@ -82,7 +81,7 @@ fn map<A: Copy Send, B: Copy Send>(xs: ~[A], f: fn~(A) -> B) -> ~[B] {
82
81
}
83
82
84
83
/// A parallel version of mapi.
85
- fn mapi < A : Copy Send , B : Copy Send > ( xs : ~[ A ] ,
84
+ pub fn mapi < A : Copy Send , B : Copy Send > ( xs : ~[ A ] ,
86
85
f : fn ~( uint , A ) -> B ) -> ~[ B ] {
87
86
let slices = map_slices( xs, || {
88
87
fn ~( base: uint, slice : & [ A ] , copy f) -> ~[ B ] {
@@ -103,7 +102,7 @@ fn mapi<A: Copy Send, B: Copy Send>(xs: ~[A],
103
102
* In this case, f is a function that creates functions to run over the
104
103
* inner elements. This is to skirt the need for copy constructors.
105
104
*/
106
- fn mapi_factory<A : Copy Send , B : Copy Send >(
105
+ pub fn mapi_factory<A : Copy Send , B : Copy Send >(
107
106
xs: & [ A ] , f : fn ( ) -> fn ~( uint, A ) -> B ) -> ~[ B ] {
108
107
let slices = map_slices( xs, || {
109
108
let f = f ( ) ;
@@ -120,7 +119,7 @@ fn mapi_factory<A: Copy Send, B: Copy Send>(
120
119
}
121
120
122
121
/// Returns true if the function holds for all elements in the vector.
123
- fn alli<A : Copy Send >( xs: ~[ A ] , f : fn ~( uint, A ) -> bool) -> bool {
122
+ pub fn alli < A : Copy Send > ( xs : ~[ A ] , f : fn ~( uint , A ) -> bool ) -> bool {
124
123
do vec:: all ( map_slices ( xs, || {
125
124
fn ~( base: uint, slice : & [ A ] , copy f) -> bool {
126
125
vec:: alli( slice , |i, x| {
@@ -131,7 +130,7 @@ fn alli<A: Copy Send>(xs: ~[A], f: fn~(uint, A) -> bool) -> bool {
131
130
}
132
131
133
132
/// Returns true if the function holds for any elements in the vector.
134
- fn any<A : Copy Send >( xs: ~[ A ] , f : fn ~( A ) -> bool) -> bool {
133
+ pub fn any< A : Copy Send > ( xs : ~[ A ] , f : fn ~( A ) -> bool ) -> bool {
135
134
do vec:: any( map_slices( xs, || {
136
135
fn ~( _base : uint, slice: & [ A ] , copy f) -> bool {
137
136
vec:: any( slice , |x| f( x) )
0 commit comments