@@ -373,6 +373,13 @@ impl<V:Clone> SmallIntMap<V> {
373
373
}
374
374
}
375
375
376
+ impl < V : PartialOrd > PartialOrd for SmallIntMap < V > {
377
+ #[ inline]
378
+ fn partial_cmp ( & self , other : & SmallIntMap < V > ) -> Option < Ordering > {
379
+ iter:: order:: partial_cmp ( self . iter ( ) , other. iter ( ) )
380
+ }
381
+ }
382
+
376
383
impl < V : fmt:: Show > fmt:: Show for SmallIntMap < V > {
377
384
fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
378
385
try!( write ! ( f, "{{" ) ) ;
@@ -770,6 +777,38 @@ mod test_map {
770
777
assert ! ( a == b) ;
771
778
}
772
779
780
+ #[ test]
781
+ fn test_lt ( ) {
782
+ let mut a = SmallIntMap :: new ( ) ;
783
+ let mut b = SmallIntMap :: new ( ) ;
784
+
785
+ assert ! ( !( a < b) && !( b < a) ) ;
786
+ assert ! ( b. insert( 2 u, 5 i) ) ;
787
+ assert ! ( a < b) ;
788
+ assert ! ( a. insert( 2 , 7 ) ) ;
789
+ assert ! ( !( a < b) && b < a) ;
790
+ assert ! ( b. insert( 1 , 0 ) ) ;
791
+ assert ! ( b < a) ;
792
+ assert ! ( a. insert( 0 , 6 ) ) ;
793
+ assert ! ( a < b) ;
794
+ assert ! ( a. insert( 6 , 2 ) ) ;
795
+ assert ! ( a < b && !( b < a) ) ;
796
+ }
797
+
798
+ #[ test]
799
+ fn test_ord ( ) {
800
+ let mut a = SmallIntMap :: new ( ) ;
801
+ let mut b = SmallIntMap :: new ( ) ;
802
+
803
+ assert ! ( a <= b && a >= b) ;
804
+ assert ! ( a. insert( 1 u, 1 i) ) ;
805
+ assert ! ( a > b && a >= b) ;
806
+ assert ! ( b < a && b <= a) ;
807
+ assert ! ( b. insert( 2 , 2 ) ) ;
808
+ assert ! ( b > a && b >= a) ;
809
+ assert ! ( a < b && a <= b) ;
810
+ }
811
+
773
812
#[ test]
774
813
fn test_hash ( ) {
775
814
let mut x = SmallIntMap :: new ( ) ;
0 commit comments