@@ -111,30 +111,6 @@ impl<T> TrieMap<T> {
111111 self . root . each_reverse ( f)
112112 }
113113
114- /// Visit all key-value pairs in order
115- #[ inline]
116- pub fn each < ' a > ( & ' a self , f : |& uint , & ' a T | -> bool ) -> bool {
117- self . root . each ( f)
118- }
119-
120- /// Visit all keys in order
121- #[ inline]
122- pub fn each_key ( & self , f: |& uint| -> bool) -> bool {
123- self . each ( |k, _| f ( k) )
124- }
125-
126- /// Visit all values in order
127- #[ inline]
128- pub fn each_value < ' a > ( & ' a self , f : |& ' a T | -> bool ) -> bool {
129- self . each ( |_, v| f ( v) )
130- }
131-
132- /// Iterate over the map and mutate the contained values
133- #[ inline]
134- pub fn mutate_values ( & mut self , f : |& uint , & mut T | -> bool) -> bool {
135- self . root . mutate_values ( f)
136- }
137-
138114 /// Visit all keys in reverse order
139115 #[ inline]
140116 pub fn each_key_reverse ( & self , f: |& uint| -> bool) -> bool {
@@ -331,10 +307,6 @@ impl TrieSet {
331307 self . map . remove ( value)
332308 }
333309
334- /// Visit all values in order
335- #[ inline]
336- pub fn each ( & self , f: |& uint| -> bool) -> bool { self . map . each_key ( f) }
337-
338310 /// Visit all values in reverse order
339311 #[ inline]
340312 pub fn each_reverse ( & self , f: |& uint| -> bool) -> bool {
@@ -395,17 +367,6 @@ impl<T> TrieNode<T> {
395367}
396368
397369impl < T > TrieNode < T > {
398- fn each < ' a > ( & ' a self , f : |& uint , & ' a T | -> bool ) -> bool {
399- for elt in self . children . iter ( ) {
400- match * elt {
401- Internal ( ref x) => if !x. each ( |i, t| f ( i, t) ) { return false } ,
402- External ( k, ref v) => if !f ( & k, v) { return false } ,
403- Nothing => ( )
404- }
405- }
406- true
407- }
408-
409370 fn each_reverse < ' a > ( & ' a self , f : |& uint , & ' a T | -> bool ) -> bool {
410371 for elt in self . children . rev_iter ( ) {
411372 match * elt {
@@ -416,19 +377,6 @@ impl<T> TrieNode<T> {
416377 }
417378 true
418379 }
419-
420- fn mutate_values < ' a > ( & ' a mut self , f : |& uint , & mut T | -> bool) -> bool {
421- for child in self . children . mut_iter ( ) {
422- match * child {
423- Internal ( ref mut x) => if !x. mutate_values ( |i, t| f ( i, t) ) {
424- return false
425- } ,
426- External ( k, ref mut v) => if !f ( & k, v) { return false } ,
427- Nothing => ( )
428- }
429- }
430- true
431- }
432380}
433381
434382// if this was done via a trait, the key could be generic
@@ -691,46 +639,6 @@ mod test_map {
691639 }
692640 }
693641
694- #[ test]
695- fn test_each ( ) {
696- let mut m = TrieMap :: new ( ) ;
697-
698- assert ! ( m. insert( 3 , 6 ) ) ;
699- assert ! ( m. insert( 0 , 0 ) ) ;
700- assert ! ( m. insert( 4 , 8 ) ) ;
701- assert ! ( m. insert( 2 , 4 ) ) ;
702- assert ! ( m. insert( 1 , 2 ) ) ;
703-
704- let mut n = 0 ;
705- m. each ( |k, v| {
706- assert_eq ! ( * k, n) ;
707- assert_eq ! ( * v, n * 2 ) ;
708- n += 1 ;
709- true
710- } ) ;
711- }
712-
713- #[ test]
714- fn test_each_break ( ) {
715- let mut m = TrieMap :: new ( ) ;
716-
717- for x in range ( uint:: max_value - 10000 , uint:: max_value) . invert ( ) {
718- m. insert ( x, x / 2 ) ;
719- }
720-
721- let mut n = uint:: max_value - 10000 ;
722- m. each ( |k, v| {
723- if n == uint:: max_value - 5000 { false } else {
724- assert ! ( n < uint:: max_value - 5000 ) ;
725-
726- assert_eq ! ( * k, n) ;
727- assert_eq ! ( * v, n / 2 ) ;
728- n += 1 ;
729- true
730- }
731- } ) ;
732- }
733-
734642 #[ test]
735643 fn test_each_reverse ( ) {
736644 let mut m = TrieMap :: new ( ) ;
@@ -943,13 +851,9 @@ mod test_set {
943851
944852 let expected = [ x, y] ;
945853
946- let mut i = 0 ;
947-
948- trie. each ( |x| {
949- assert_eq ! ( expected[ i] , * x) ;
950- i += 1 ;
951- true
952- } ) ;
854+ for ( i, x) in trie. iter ( ) . enumerate ( ) {
855+ assert_eq ! ( expected[ i] , x) ;
856+ }
953857 }
954858
955859 #[ test]
0 commit comments