@@ -293,32 +293,46 @@ impl Mutable for TrieSet {
293293 fn clear ( & mut self ) { self . map . clear ( ) }
294294}
295295
296- impl TrieSet {
297- /// Create an empty TrieSet
296+ impl Set < uint > for TrieSet {
298297 #[ inline]
299- pub fn new ( ) -> TrieSet {
300- TrieSet { map : TrieMap :: new ( ) }
298+ fn contains ( & self , value : & uint ) -> bool {
299+ self . map . contains_key ( value )
301300 }
302301
303- /// Return true if the set contains a value
304302 #[ 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 ) )
307305 }
308306
309- /// Add a value to the set. Return true if the value was not already
310- /// present in the set.
311307 #[ 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 {
313321 self . map . insert ( value, ( ) )
314322 }
315323
316- /// Remove a value from the set. Return true if the value was
317- /// present in the set.
318324 #[ inline]
319- pub fn remove ( & mut self , value : & uint ) -> bool {
325+ fn remove ( & mut self , value : & uint ) -> bool {
320326 self . map . remove ( value)
321327 }
328+ }
329+
330+ impl TrieSet {
331+ /// Create an empty TrieSet
332+ #[ inline]
333+ pub fn new ( ) -> TrieSet {
334+ TrieSet { map : TrieMap :: new ( ) }
335+ }
322336
323337 /// Visit all values in reverse order
324338 #[ inline]
0 commit comments