@@ -376,27 +376,6 @@ impl Bitv {
376376 }
377377 }
378378
379- /**
380- * Compares two bitvectors
381- *
382- * Both bitvectors must be the same length. Returns `true` if both
383- * bitvectors contain identical elements.
384- */
385- #[ inline]
386- pub fn equal ( & self , v1 : & Bitv ) -> bool {
387- if self . nbits != v1. nbits { return false ; }
388- match self . rep {
389- Small ( ref b) => match v1. rep {
390- Small ( ref b1) => b. equals ( b1, self . nbits ) ,
391- _ => false
392- } ,
393- Big ( ref s) => match v1. rep {
394- Big ( ref s1) => s. equals ( s1, self . nbits ) ,
395- Small ( _) => return false
396- }
397- }
398- }
399-
400379 /// Set all bits to 0
401380 #[ inline]
402381 pub fn clear ( & mut self ) {
@@ -613,6 +592,25 @@ impl<S: hash::Writer> hash::Hash<S> for Bitv {
613592 }
614593}
615594
595+ impl cmp:: PartialEq for Bitv {
596+ #[ inline]
597+ fn eq ( & self , other : & Bitv ) -> bool {
598+ if self . nbits != other. nbits { return false ; }
599+ match self . rep {
600+ Small ( ref b) => match other. rep {
601+ Small ( ref b1) => b. equals ( b1, self . nbits ) ,
602+ _ => false
603+ } ,
604+ Big ( ref s) => match other. rep {
605+ Big ( ref s1) => s. equals ( s1, self . nbits ) ,
606+ Small ( _) => return false
607+ }
608+ }
609+ }
610+ }
611+
612+ impl cmp:: Eq for Bitv { }
613+
616614#[ inline]
617615fn iterate_bits ( base : uint , bits : uint , f: |uint| -> bool) -> bool {
618616 if bits == 0 {
@@ -841,6 +839,8 @@ impl cmp::PartialEq for BitvSet {
841839 fn ne ( & self , other : & BitvSet ) -> bool { !self . eq ( other) }
842840}
843841
842+ impl cmp:: Eq for BitvSet { }
843+
844844impl fmt:: Show for BitvSet {
845845 fn fmt ( & self , fmt : & mut fmt:: Formatter ) -> fmt:: Result {
846846 try!( write ! ( fmt, "{{" ) ) ;
@@ -1323,14 +1323,14 @@ mod tests {
13231323 fn test_equal_differing_sizes ( ) {
13241324 let v0 = Bitv :: new ( 10 u, false ) ;
13251325 let v1 = Bitv :: new ( 11 u, false ) ;
1326- assert ! ( !v0 . equal ( & v1 ) ) ;
1326+ assert ! ( v0 != v1 ) ;
13271327 }
13281328
13291329 #[ test]
13301330 fn test_equal_greatly_differing_sizes ( ) {
13311331 let v0 = Bitv :: new ( 10 u, false ) ;
13321332 let v1 = Bitv :: new ( 110 u, false ) ;
1333- assert ! ( !v0 . equal ( & v1 ) ) ;
1333+ assert ! ( v0 != v1 ) ;
13341334 }
13351335
13361336 #[ test]
@@ -1341,7 +1341,7 @@ mod tests {
13411341 let mut b = bitv:: Bitv :: new ( 1 , true ) ;
13421342 b. set ( 0 , true ) ;
13431343
1344- assert ! ( a. equal ( & b ) ) ;
1344+ assert_eq ! ( a, b ) ;
13451345 }
13461346
13471347 #[ test]
@@ -1356,7 +1356,7 @@ mod tests {
13561356 b. set ( i, true ) ;
13571357 }
13581358
1359- assert ! ( a. equal ( & b ) ) ;
1359+ assert_eq ! ( a, b ) ;
13601360 }
13611361
13621362 #[ test]
0 commit comments