@@ -293,32 +293,46 @@ impl Mutable for TrieSet {
293
293
fn clear ( & mut self ) { self . map . clear ( ) }
294
294
}
295
295
296
- impl TrieSet {
297
- /// Create an empty TrieSet
296
+ impl Set < uint > for TrieSet {
298
297
#[ inline]
299
- pub fn new ( ) -> TrieSet {
300
- TrieSet { map : TrieMap :: new ( ) }
298
+ fn contains ( & self , value : & uint ) -> bool {
299
+ self . map . contains_key ( value )
301
300
}
302
301
303
- /// Return true if the set contains a value
304
302
#[ inline]
305
- pub fn contains ( & self , value : & uint ) -> bool {
306
- self . map . contains_key ( value )
303
+ fn is_disjoint ( & self , other : & TrieSet ) -> bool {
304
+ self . iter ( ) . all ( |v| !other . contains ( & v ) )
307
305
}
308
306
309
- /// Add a value to the set. Return true if the value was not already
310
- /// present in the set.
311
307
#[ inline]
312
- pub fn insert ( & mut self , value : uint ) -> bool {
308
+ fn is_subset ( & self , other : & TrieSet ) -> bool {
309
+ self . iter ( ) . all ( |v| other. contains ( & v) )
310
+ }
311
+
312
+ #[ inline]
313
+ fn is_superset ( & self , other : & TrieSet ) -> bool {
314
+ other. is_subset ( self )
315
+ }
316
+ }
317
+
318
+ impl MutableSet < uint > for TrieSet {
319
+ #[ inline]
320
+ fn insert ( & mut self , value : uint ) -> bool {
313
321
self . map . insert ( value, ( ) )
314
322
}
315
323
316
- /// Remove a value from the set. Return true if the value was
317
- /// present in the set.
318
324
#[ inline]
319
- pub fn remove ( & mut self , value : & uint ) -> bool {
325
+ fn remove ( & mut self , value : & uint ) -> bool {
320
326
self . map . remove ( value)
321
327
}
328
+ }
329
+
330
+ impl TrieSet {
331
+ /// Create an empty TrieSet
332
+ #[ inline]
333
+ pub fn new ( ) -> TrieSet {
334
+ TrieSet { map : TrieMap :: new ( ) }
335
+ }
322
336
323
337
/// Visit all values in reverse order
324
338
#[ inline]
0 commit comments