14
14
15
15
#[ forbid( deprecated_mode) ] ;
16
16
17
+ use core:: container:: Set ;
17
18
use core:: cmp:: { Eq , Ord } ;
18
19
use core:: option:: { Option , Some , None } ;
19
20
use core:: prelude:: * ;
@@ -197,6 +198,21 @@ impl <T: Eq Ord> TreeSet<T>: Eq {
197
198
pure fn ne( & self , other: & TreeSet <T >) -> bool { self . map != other. map }
198
199
}
199
200
201
+ impl <T : Ord > TreeSet <T >: Set <T > {
202
+ /// Return true if the set contains a value
203
+ pure fn contains( & self , value: & T ) -> bool {
204
+ self . map. contains_key( value)
205
+ }
206
+
207
+ /// Add a value to the set. Return true if the value was not already
208
+ /// present in the set.
209
+ fn insert( & mut self , value: T ) -> bool { self . map. insert( value, ( ) ) }
210
+
211
+ /// Remove a value from the set. Return true if the value was
212
+ /// present in the set.
213
+ fn remove( & mut self , value: & T ) -> bool { self . map. remove( value) }
214
+ }
215
+
200
216
impl <T : Ord > TreeSet <T > {
201
217
/// Create an empty TreeSet
202
218
static pure fn new( ) -> TreeSet <T > { TreeSet { map: TreeMap :: new ( ) } }
@@ -215,19 +231,6 @@ impl <T: Ord> TreeSet<T> {
215
231
self . map. each_key_reverse( f)
216
232
}
217
233
218
- /// Return true if the set contains a value
219
- pure fn contains( & self , value: & T ) -> bool {
220
- self . map. contains_key( value)
221
- }
222
-
223
- /// Add a value to the set. Return true if the value was not
224
- /// already present in the set.
225
- fn insert( & mut self , value: T ) -> bool { self . map. insert( value, ( ) ) }
226
-
227
- /// Remove a value from the set. Return true if the value was
228
- /// present in the set.
229
- fn remove( & mut self , value: & T ) -> bool { self . map. remove( value) }
230
-
231
234
/// Get a lazy iterator over the values in the set.
232
235
/// Requires that it be frozen (immutable).
233
236
pure fn iter( & self ) -> TreeSetIterator /& self <T > {
0 commit comments