@@ -20,45 +20,6 @@ type node_id = i64;
20
20
type graph = [ [ node_id ] ] ;
21
21
type bfs_result = [ node_id ] ;
22
22
23
- iface queue<T : send> {
24
- fn add_back ( T ) ;
25
- fn pop_front ( ) -> T ;
26
- fn size ( ) -> uint ;
27
- }
28
-
29
- #[ doc="Creates a queue based on ports and channels.
30
-
31
- This is admittedly not ideal, but it will help us work around the deque
32
- bugs for the time being." ]
33
- fn create_queue < T : send > ( ) -> queue < T > {
34
- type repr < T : send > = {
35
- p : port < T > ,
36
- c : chan < T > ,
37
- mut s : uint ,
38
- } ;
39
-
40
- let p = port ( ) ;
41
- let c = chan ( p) ;
42
-
43
- impl < T : copy send> of queue < T > for repr < T > {
44
- fn add_back ( x : T ) {
45
- let x = x;
46
- send ( self . c , x) ;
47
- self . s += 1 u;
48
- }
49
-
50
- fn pop_front ( ) -> T {
51
- self . s -= 1 u;
52
- recv ( self . p )
53
- }
54
-
55
- fn size ( ) -> uint { self . s }
56
- }
57
-
58
- let Q : repr < T > = { p : p, c : c, mut s : 0 u } ;
59
- Q as queue :: < T >
60
- }
61
-
62
23
fn make_edges ( scale : uint , edgefactor : uint ) -> [ ( node_id , node_id ) ] {
63
24
let r = rand:: rng ( ) ;
64
25
@@ -145,7 +106,7 @@ fn bfs(graph: graph, key: node_id) -> bfs_result {
145
106
let marks : [ mut node_id ]
146
107
= vec:: to_mut ( vec:: from_elem ( vec:: len ( graph) , -1i64 ) ) ;
147
108
148
- let Q = create_queue ( ) ;
109
+ let Q = deque :: create ( ) ;
149
110
150
111
Q . add_back ( key) ;
151
112
marks[ key] = key;
@@ -266,7 +227,7 @@ fn pbfs(graph: graph, key: node_id) -> bfs_result {
266
227
}
267
228
}
268
229
269
- let ( res , graph) = arc:: shared_arc ( copy graph) ;
230
+ let ( _res , graph) = arc:: shared_arc ( copy graph) ;
270
231
271
232
let mut i = 0 u;
272
233
while par:: any ( colors, is_gray) {
@@ -275,24 +236,24 @@ fn pbfs(graph: graph, key: node_id) -> bfs_result {
275
236
i += 1 u;
276
237
let old_len = colors. len ( ) ;
277
238
278
- let ( res , color) = arc:: shared_arc ( copy colors) ;
239
+ let ( _res , color) = arc:: shared_arc ( copy colors) ;
279
240
280
241
colors = par:: mapi ( colors) { |i, c|
281
242
let c : color = c;
282
243
let colors = & arc:: get_arc ( color) ;
283
- let colors : [ color ] = * arc:: get ( colors) ;
244
+ let colors = arc:: get ( colors) ;
284
245
let graph = & arc:: get_arc ( graph) ;
285
- let graph : graph = * arc:: get ( graph) ;
246
+ let graph = arc:: get ( graph) ;
286
247
alt c {
287
248
white {
288
249
let i = i as node_id ;
289
250
290
- let neighbors = graph[ i] ;
251
+ let neighbors = ( * graph) [ i] ;
291
252
292
253
let mut color = white;
293
254
294
255
neighbors. each ( ) { |k|
295
- if is_gray ( colors[ k] ) {
256
+ if is_gray ( ( * colors) [ k] ) {
296
257
color = gray ( k) ;
297
258
false
298
259
}
0 commit comments