File tree Expand file tree Collapse file tree 1 file changed +13
-1
lines changed Expand file tree Collapse file tree 1 file changed +13
-1
lines changed Original file line number Diff line number Diff line change 14
14
*/
15
15
16
16
use core:: container:: { Container , Mutable , Map , Set } ;
17
- use core:: iter:: BaseIter ;
17
+ use core:: iter:: { BaseIter , ReverseIter } ;
18
18
use core:: option:: { Some , None } ;
19
19
use core:: prelude:: * ;
20
20
@@ -36,6 +36,18 @@ impl<V> SmallIntMap<V>: BaseIter<(uint, &V)> {
36
36
pure fn size_hint ( & self ) -> Option < uint > { Some ( self . len ( ) ) }
37
37
}
38
38
39
+ impl < V > SmallIntMap < V > : ReverseIter < ( uint , & V ) > {
40
+ /// Visit all key-value pairs in reverse order
41
+ pure fn each_reverse ( & self , it : fn ( & ( uint, & self /V ) ) -> bool ) {
42
+ for uint:: range_rev( self . v. len( ) , 0 ) |i| {
43
+ match self . v [ i - 1 ] {
44
+ Some ( ref elt) => if !it ( & ( i - 1 , elt) ) { break } ,
45
+ None => ( )
46
+ }
47
+ }
48
+ }
49
+ }
50
+
39
51
impl < V > SmallIntMap < V > : Container {
40
52
/// Return the number of elements in the map
41
53
pure fn len ( & self ) -> uint {
You can’t perform that action at this time.
0 commit comments