@@ -77,21 +77,13 @@ pure fn lt<K: Ord + TotalOrd, V>(a: &TreeMap<K, V>,
77
77
78
78
impl <K : Ord + TotalOrd , V > Ord for TreeMap < K , V > {
79
79
#[ inline( always) ]
80
- pure fn lt ( & self , other : & TreeMap < K , V > ) -> bool {
81
- lt ( self , other)
82
- }
80
+ pure fn lt ( & self , other : & TreeMap < K , V > ) -> bool { lt ( self , other) }
83
81
#[ inline( always) ]
84
- pure fn le ( & self , other : & TreeMap < K , V > ) -> bool {
85
- !lt ( other, self )
86
- }
82
+ pure fn le ( & self , other : & TreeMap < K , V > ) -> bool { !lt ( other, self ) }
87
83
#[ inline( always) ]
88
- pure fn ge ( & self , other : & TreeMap < K , V > ) -> bool {
89
- !lt ( self , other)
90
- }
84
+ pure fn ge ( & self , other : & TreeMap < K , V > ) -> bool { !lt ( self , other) }
91
85
#[ inline( always) ]
92
- pure fn gt ( & self , other : & TreeMap < K , V > ) -> bool {
93
- lt ( other, self )
94
- }
86
+ pure fn gt ( & self , other : & TreeMap < K , V > ) -> bool { lt ( other, self ) }
95
87
}
96
88
97
89
impl < ' self , K : TotalOrd , V > BaseIter < ( & ' self K , & ' self V ) > for TreeMap < K , V > {
@@ -244,19 +236,24 @@ pub struct TreeSet<T> {
244
236
245
237
impl < T : TotalOrd > BaseIter < T > for TreeSet < T > {
246
238
/// Visit all values in order
239
+ #[ inline( always) ]
247
240
pure fn each ( & self , f : & fn ( & T ) -> bool ) { self . map . each_key ( f) }
241
+ #[ inline( always) ]
248
242
pure fn size_hint ( & self ) -> Option < uint > { Some ( self . len ( ) ) }
249
243
}
250
244
251
245
impl < T : TotalOrd > ReverseIter < T > for TreeSet < T > {
252
246
/// Visit all values in reverse order
247
+ #[ inline( always) ]
253
248
pure fn each_reverse ( & self , f : & fn ( & T ) -> bool ) {
254
249
self . map . each_key_reverse ( f)
255
250
}
256
251
}
257
252
258
253
impl < T : Eq + TotalOrd > Eq for TreeSet < T > {
254
+ #[ inline( always) ]
259
255
pure fn eq ( & self , other : & TreeSet < T > ) -> bool { self . map == other. map }
256
+ #[ inline( always) ]
260
257
pure fn ne ( & self , other : & TreeSet < T > ) -> bool { self . map != other. map }
261
258
}
262
259
@@ -273,29 +270,35 @@ impl<T: Ord + TotalOrd> Ord for TreeSet<T> {
273
270
274
271
impl < T : TotalOrd > Container for TreeSet < T > {
275
272
/// Return the number of elements in the set
273
+ #[ inline( always) ]
276
274
pure fn len ( & self ) -> uint { self . map . len ( ) }
277
275
278
276
/// Return true if the set contains no elements
277
+ #[ inline( always) ]
279
278
pure fn is_empty ( & self ) -> bool { self . map . is_empty ( ) }
280
279
}
281
280
282
281
impl < T : TotalOrd > Mutable for TreeSet < T > {
283
282
/// Clear the set, removing all values.
283
+ #[ inline( always) ]
284
284
fn clear ( & mut self ) { self . map . clear ( ) }
285
285
}
286
286
287
287
impl < T : TotalOrd > Set < T > for TreeSet < T > {
288
288
/// Return true if the set contains a value
289
+ #[ inline( always) ]
289
290
pure fn contains ( & self , value : & T ) -> bool {
290
291
self . map . contains_key ( value)
291
292
}
292
293
293
294
/// Add a value to the set. Return true if the value was not already
294
295
/// present in the set.
296
+ #[ inline( always) ]
295
297
fn insert ( & mut self , value : T ) -> bool { self . map . insert ( value, ( ) ) }
296
298
297
299
/// Remove a value from the set. Return true if the value was
298
300
/// present in the set.
301
+ #[ inline( always) ]
299
302
fn remove ( & mut self , value : & T ) -> bool { self . map . remove ( value) }
300
303
301
304
/// Return true if the set has no elements in common with `other`.
@@ -320,6 +323,7 @@ impl<T: TotalOrd> Set<T> for TreeSet<T> {
320
323
}
321
324
322
325
/// Return true if the set is a subset of another
326
+ #[ inline( always) ]
323
327
pure fn is_subset ( & self , other : & TreeSet < T > ) -> bool {
324
328
other. is_superset ( self )
325
329
}
@@ -488,10 +492,12 @@ impl<T: TotalOrd> Set<T> for TreeSet<T> {
488
492
489
493
pub impl < T : TotalOrd > TreeSet < T > {
490
494
/// Create an empty TreeSet
495
+ #[ inline( always) ]
491
496
static pure fn new( ) -> TreeSet <T > { TreeSet { map: TreeMap :: new( ) } }
492
497
493
498
/// Get a lazy iterator over the values in the set.
494
499
/// Requires that it be frozen (immutable).
500
+ #[ inline( always) ]
495
501
pure fn iter ( & self ) -> TreeSetIterator /& self <T > {
496
502
TreeSetIterator { iter: self . map . iter ( ) }
497
503
}
@@ -504,11 +510,13 @@ pub struct TreeSetIterator<T> {
504
510
505
511
/// Advance the iterator to the next node (in order). If this iterator is
506
512
/// finished, does nothing.
513
+ #[ inline( always) ]
507
514
pub fn set_next<T >( iter: & mut TreeSetIterator /& r<T >) -> Option <& r/T > {
508
515
do map_next( & mut iter. iter) . map |& ( value, _) | { value }
509
516
}
510
517
511
518
/// Advance the iterator through the set
519
+ #[ inline( always) ]
512
520
pub fn set_advance<T >( iter: & mut TreeSetIterator /& r<T >,
513
521
f: & fn ( & r/T ) -> bool ) {
514
522
do map_advance( & mut iter. iter) |( k, _) | { f( k) }
0 commit comments