@@ -56,38 +56,6 @@ impl<V> Map<uint, V> for SmallIntMap<V> {
5656 self . find ( key) . is_some ( )
5757 }
5858
59- /// Visit all key-value pairs in order
60- fn each < ' a > ( & ' a self , it : & fn ( & uint , & ' a V ) -> bool ) -> bool {
61- for uint:: range( 0 , self . v. len( ) ) |i| {
62- match self . v [ i] {
63- Some ( ref elt) => if !it ( & i, elt) { return false ; } ,
64- None => ( )
65- }
66- }
67- return true ;
68- }
69-
70- /// Visit all keys in order
71- fn each_key ( & self , blk : & fn ( key : & uint ) -> bool ) -> bool {
72- self . each ( |k, _| blk ( k) )
73- }
74-
75- /// Visit all values in order
76- fn each_value < ' a > ( & ' a self , blk : & fn ( value : & ' a V ) -> bool ) -> bool {
77- self . each ( |_, v| blk ( v) )
78- }
79-
80- /// Iterate over the map and mutate the contained values
81- fn mutate_values ( & mut self , it : & fn ( & uint , & mut V ) -> bool ) -> bool {
82- for uint:: range( 0 , self . v. len( ) ) |i| {
83- match self . v [ i] {
84- Some ( ref mut elt) => if !it ( & i, elt) { return false ; } ,
85- None => ( )
86- }
87- }
88- return true ;
89- }
90-
9159 /// Return a reference to the value corresponding to the key
9260 fn find < ' a > ( & ' a self , key : & uint ) -> Option < & ' a V > {
9361 if * key < self . v . len ( ) {
@@ -156,6 +124,38 @@ impl<V> SmallIntMap<V> {
156124 /// Create an empty SmallIntMap
157125 pub fn new ( ) -> SmallIntMap < V > { SmallIntMap { v : ~[ ] } }
158126
127+ /// Visit all key-value pairs in order
128+ pub fn each < ' a > ( & ' a self , it : & fn ( & uint , & ' a V ) -> bool ) -> bool {
129+ for uint:: range( 0 , self . v. len( ) ) |i| {
130+ match self . v [ i] {
131+ Some ( ref elt) => if !it ( & i, elt) { return false ; } ,
132+ None => ( )
133+ }
134+ }
135+ return true ;
136+ }
137+
138+ /// Visit all keys in order
139+ pub fn each_key ( & self , blk : & fn ( key : & uint ) -> bool ) -> bool {
140+ self . each ( |k, _| blk ( k) )
141+ }
142+
143+ /// Visit all values in order
144+ pub fn each_value < ' a > ( & ' a self , blk : & fn ( value : & ' a V ) -> bool ) -> bool {
145+ self . each ( |_, v| blk ( v) )
146+ }
147+
148+ /// Iterate over the map and mutate the contained values
149+ pub fn mutate_values ( & mut self , it : & fn ( & uint , & mut V ) -> bool ) -> bool {
150+ for uint:: range( 0 , self . v. len( ) ) |i| {
151+ match self . v [ i] {
152+ Some ( ref mut elt) => if !it ( & i, elt) { return false ; } ,
153+ None => ( )
154+ }
155+ }
156+ return true ;
157+ }
158+
159159 /// Visit all key-value pairs in reverse order
160160 pub fn each_reverse < ' a > ( & ' a self , it : & fn ( uint , & ' a V ) -> bool ) -> bool {
161161 for uint:: range_rev( self . v. len( ) , 0 ) |i| {
0 commit comments