@@ -229,13 +229,13 @@ impl <T: Ord> TreeSet<T> {
229
229
/// Return true if the set has no elements in common with `other`.
230
230
/// This is equivalent to checking for an empty intersection.
231
231
pure fn is_disjoint( & self , other: & TreeSet <T >) -> bool {
232
- // FIXME: this is a naive O(n*log(m)) implementation, could be O(n)
232
+ // FIXME: this is a naive O(n*log(m)) implementation, could be O(n + m )
233
233
!iter:: any( self , |x| other. contains( x) )
234
234
}
235
235
236
236
/// Check of the set is a subset of another
237
237
pure fn is_subset( & self , other: & TreeSet <T >) -> bool {
238
- // FIXME: this is a naive O(n*log(m)) implementation, could be O(n)
238
+ // FIXME: this is a naive O(n*log(m)) implementation, could be O(n + m )
239
239
!iter:: any( self , |x| !other. contains( x) )
240
240
}
241
241
@@ -278,14 +278,21 @@ impl <T: Ord> TreeSet<T> {
278
278
}
279
279
280
280
/// Visit the values (in-order) representing the symmetric difference
281
- pure fn symmetric_difference ( & self , _other : & TreeSet < T > ,
281
+ pure fn symmetric_difference ( & self , other : & TreeSet < T > ,
282
282
_f : fn ( & T ) -> bool ) {
283
+ unsafe { // purity workaround
284
+ let mut x = self . map . iter ( ) ;
285
+ let mut y = other. map . iter ( ) ;
286
+
287
+ let mut a = x. next ( ) ;
288
+ let mut b = y. next ( ) ;
289
+ }
283
290
fail ~"not yet implemented"
284
291
}
285
292
286
293
/// Visit the values (in-order) representing the intersection
287
294
pure fn intersection ( & self , other : & TreeSet < T > , f : fn ( & T ) -> bool ) {
288
- // FIXME: this is a naive O(n*log(m)) implementation, could be O(n)
295
+ // FIXME: this is a naive O(n*log(m)) implementation, could be O(n + m )
289
296
for self . each |x| {
290
297
if other. contains ( x) {
291
298
if !f ( x) { break }
@@ -294,7 +301,14 @@ impl <T: Ord> TreeSet<T> {
294
301
}
295
302
296
303
/// Visit the values (in-order) representing the union
297
- pure fn union ( & self , _other : & TreeSet < T > , _f : fn ( & T ) -> bool ) {
304
+ pure fn union ( & self , other : & TreeSet < T > , _f : fn ( & T ) -> bool ) {
305
+ unsafe { // purity workaround
306
+ let mut x = self . map . iter ( ) ;
307
+ let mut y = other. map . iter ( ) ;
308
+
309
+ let mut a = x. next ( ) ;
310
+ let mut b = y. next ( ) ;
311
+ }
298
312
fail ~"not yet implemented"
299
313
}
300
314
}
0 commit comments