@@ -111,30 +111,6 @@ impl<T> TrieMap<T> {
111
111
self . root . each_reverse ( f)
112
112
}
113
113
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
-
138
114
/// Visit all keys in reverse order
139
115
#[ inline]
140
116
pub fn each_key_reverse ( & self , f: |& uint| -> bool) -> bool {
@@ -331,10 +307,6 @@ impl TrieSet {
331
307
self . map . remove ( value)
332
308
}
333
309
334
- /// Visit all values in order
335
- #[ inline]
336
- pub fn each ( & self , f: |& uint| -> bool) -> bool { self . map . each_key ( f) }
337
-
338
310
/// Visit all values in reverse order
339
311
#[ inline]
340
312
pub fn each_reverse ( & self , f: |& uint| -> bool) -> bool {
@@ -395,17 +367,6 @@ impl<T> TrieNode<T> {
395
367
}
396
368
397
369
impl < 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
-
409
370
fn each_reverse < ' a > ( & ' a self , f : |& uint , & ' a T | -> bool ) -> bool {
410
371
for elt in self . children . rev_iter ( ) {
411
372
match * elt {
@@ -416,19 +377,6 @@ impl<T> TrieNode<T> {
416
377
}
417
378
true
418
379
}
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
- }
432
380
}
433
381
434
382
// if this was done via a trait, the key could be generic
@@ -691,46 +639,6 @@ mod test_map {
691
639
}
692
640
}
693
641
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
-
734
642
#[ test]
735
643
fn test_each_reverse ( ) {
736
644
let mut m = TrieMap :: new ( ) ;
@@ -943,13 +851,9 @@ mod test_set {
943
851
944
852
let expected = [ x, y] ;
945
853
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
+ }
953
857
}
954
858
955
859
#[ test]
0 commit comments