@@ -670,21 +670,21 @@ pub trait DoubleEndedIterator<A>: Iterator<A> {
670
670
/// Yield an element from the end of the range, returning `None` if the range is empty.
671
671
fn next_back ( & mut self ) -> Option < A > ;
672
672
673
- /// Flip the direction of the iterator
673
+ /// Change the direction of the iterator
674
674
///
675
- /// The inverted iterator flips the ends on an iterator that can already
675
+ /// The flipped iterator swaps the ends on an iterator that can already
676
676
/// be iterated from the front and from the back.
677
677
///
678
678
///
679
- /// If the iterator also implements RandomAccessIterator, the inverted
679
+ /// If the iterator also implements RandomAccessIterator, the flipped
680
680
/// iterator is also random access, with the indices starting at the back
681
681
/// of the original iterator.
682
682
///
683
- /// Note: Random access with inverted indices still only applies to the first
683
+ /// Note: Random access with flipped indices still only applies to the first
684
684
/// `uint::max_value` elements of the original iterator.
685
685
#[ inline]
686
- fn invert ( self ) -> Invert < Self > {
687
- Invert { iter : self }
686
+ fn rev ( self ) -> Rev < Self > {
687
+ Rev { iter : self }
688
688
}
689
689
}
690
690
@@ -759,30 +759,30 @@ pub trait ExactSize<A> : DoubleEndedIterator<A> {
759
759
// Adaptors that may overflow in `size_hint` are not, i.e. `Chain`.
760
760
impl < A , T : ExactSize < A > > ExactSize < ( uint , A ) > for Enumerate < T > { }
761
761
impl < ' a , A , T : ExactSize < A > > ExactSize < A > for Inspect < ' a , A , T > { }
762
- impl < A , T : ExactSize < A > > ExactSize < A > for Invert < T > { }
762
+ impl < A , T : ExactSize < A > > ExactSize < A > for Rev < T > { }
763
763
impl < ' a , A , B , T : ExactSize < A > > ExactSize < B > for Map < ' a , A , B , T > { }
764
764
impl < A , B , T : ExactSize < A > , U : ExactSize < B > > ExactSize < ( A , B ) > for Zip < T , U > { }
765
765
766
766
/// An double-ended iterator with the direction inverted
767
767
#[ deriving( Clone ) ]
768
- pub struct Invert < T > {
768
+ pub struct Rev < T > {
769
769
priv iter : T
770
770
}
771
771
772
- impl < A , T : DoubleEndedIterator < A > > Iterator < A > for Invert < T > {
772
+ impl < A , T : DoubleEndedIterator < A > > Iterator < A > for Rev < T > {
773
773
#[ inline]
774
774
fn next ( & mut self ) -> Option < A > { self . iter . next_back ( ) }
775
775
#[ inline]
776
776
fn size_hint ( & self ) -> ( uint , Option < uint > ) { self . iter . size_hint ( ) }
777
777
}
778
778
779
- impl < A , T : DoubleEndedIterator < A > > DoubleEndedIterator < A > for Invert < T > {
779
+ impl < A , T : DoubleEndedIterator < A > > DoubleEndedIterator < A > for Rev < T > {
780
780
#[ inline]
781
781
fn next_back ( & mut self ) -> Option < A > { self . iter . next ( ) }
782
782
}
783
783
784
784
impl < A , T : DoubleEndedIterator < A > + RandomAccessIterator < A > > RandomAccessIterator < A >
785
- for Invert < T > {
785
+ for Rev < T > {
786
786
#[ inline]
787
787
fn indexable ( & self ) -> uint { self . iter . indexable ( ) }
788
788
#[ inline]
@@ -2590,12 +2590,12 @@ mod tests {
2590
2590
}
2591
2591
2592
2592
#[ test]
2593
- fn test_invert ( ) {
2593
+ fn test_rev ( ) {
2594
2594
let xs = [ 2 , 4 , 6 , 8 , 10 , 12 , 14 , 16 ] ;
2595
2595
let mut it = xs. iter ( ) ;
2596
2596
it. next ( ) ;
2597
2597
it. next ( ) ;
2598
- assert_eq ! ( it. invert ( ) . map( |& x| x) . collect:: <~[ int] >( ) , ~[ 16 , 14 , 12 , 10 , 8 , 6 ] ) ;
2598
+ assert_eq ! ( it. rev ( ) . map( |& x| x) . collect:: <~[ int] >( ) , ~[ 16 , 14 , 12 , 10 , 8 , 6 ] ) ;
2599
2599
}
2600
2600
2601
2601
#[ test]
@@ -2662,7 +2662,7 @@ mod tests {
2662
2662
fn test_double_ended_chain ( ) {
2663
2663
let xs = [ 1 , 2 , 3 , 4 , 5 ] ;
2664
2664
let ys = ~[ 7 , 9 , 11 ] ;
2665
- let mut it = xs. iter ( ) . chain ( ys. iter ( ) ) . invert ( ) ;
2665
+ let mut it = xs. iter ( ) . chain ( ys. iter ( ) ) . rev ( ) ;
2666
2666
assert_eq ! ( it. next( ) . unwrap( ) , & 11 )
2667
2667
assert_eq ! ( it. next( ) . unwrap( ) , & 9 )
2668
2668
assert_eq ! ( it. next_back( ) . unwrap( ) , & 1 )
@@ -2764,10 +2764,10 @@ mod tests {
2764
2764
}
2765
2765
2766
2766
#[ test]
2767
- fn test_random_access_invert ( ) {
2767
+ fn test_random_access_rev ( ) {
2768
2768
let xs = [ 1 , 2 , 3 , 4 , 5 ] ;
2769
- check_randacc_iter ( xs. iter ( ) . invert ( ) , xs. len ( ) ) ;
2770
- let mut it = xs. iter ( ) . invert ( ) ;
2769
+ check_randacc_iter ( xs. iter ( ) . rev ( ) , xs. len ( ) ) ;
2770
+ let mut it = xs. iter ( ) . rev ( ) ;
2771
2771
it. next ( ) ;
2772
2772
it. next_back ( ) ;
2773
2773
it. next ( ) ;
@@ -2833,13 +2833,13 @@ mod tests {
2833
2833
2834
2834
#[ test]
2835
2835
fn test_double_ended_range ( ) {
2836
- assert_eq ! ( range( 11 i, 14 ) . invert ( ) . collect:: <~[ int] >( ) , ~[ 13 i, 12 , 11 ] ) ;
2837
- for _ in range ( 10 i, 0 ) . invert ( ) {
2836
+ assert_eq ! ( range( 11 i, 14 ) . rev ( ) . collect:: <~[ int] >( ) , ~[ 13 i, 12 , 11 ] ) ;
2837
+ for _ in range ( 10 i, 0 ) . rev ( ) {
2838
2838
fail ! ( "unreachable" ) ;
2839
2839
}
2840
2840
2841
- assert_eq ! ( range( 11 u, 14 ) . invert ( ) . collect:: <~[ uint] >( ) , ~[ 13 u, 12 , 11 ] ) ;
2842
- for _ in range ( 10 u, 0 ) . invert ( ) {
2841
+ assert_eq ! ( range( 11 u, 14 ) . rev ( ) . collect:: <~[ uint] >( ) , ~[ 13 u, 12 , 11 ] ) ;
2842
+ for _ in range ( 10 u, 0 ) . rev ( ) {
2843
2843
fail ! ( "unreachable" ) ;
2844
2844
}
2845
2845
}
@@ -2886,11 +2886,11 @@ mod tests {
2886
2886
2887
2887
assert_eq ! ( range( 0 i, 5 ) . collect:: <~[ int] >( ) , ~[ 0 i, 1 , 2 , 3 , 4 ] ) ;
2888
2888
assert_eq ! ( range( -10 i, -1 ) . collect:: <~[ int] >( ) , ~[ -10 , -9 , -8 , -7 , -6 , -5 , -4 , -3 , -2 ] ) ;
2889
- assert_eq ! ( range( 0 i, 5 ) . invert ( ) . collect:: <~[ int] >( ) , ~[ 4 , 3 , 2 , 1 , 0 ] ) ;
2889
+ assert_eq ! ( range( 0 i, 5 ) . rev ( ) . collect:: <~[ int] >( ) , ~[ 4 , 3 , 2 , 1 , 0 ] ) ;
2890
2890
assert_eq ! ( range( 200 , -5 ) . collect:: <~[ int] >( ) , ~[ ] ) ;
2891
- assert_eq ! ( range( 200 , -5 ) . invert ( ) . collect:: <~[ int] >( ) , ~[ ] ) ;
2891
+ assert_eq ! ( range( 200 , -5 ) . rev ( ) . collect:: <~[ int] >( ) , ~[ ] ) ;
2892
2892
assert_eq ! ( range( 200 , 200 ) . collect:: <~[ int] >( ) , ~[ ] ) ;
2893
- assert_eq ! ( range( 200 , 200 ) . invert ( ) . collect:: <~[ int] >( ) , ~[ ] ) ;
2893
+ assert_eq ! ( range( 200 , 200 ) . rev ( ) . collect:: <~[ int] >( ) , ~[ ] ) ;
2894
2894
2895
2895
assert_eq ! ( range( 0 i, 100 ) . size_hint( ) , ( 100 , Some ( 100 ) ) ) ;
2896
2896
// this test is only meaningful when sizeof uint < sizeof u64
@@ -2902,11 +2902,11 @@ mod tests {
2902
2902
#[ test]
2903
2903
fn test_range_inclusive ( ) {
2904
2904
assert_eq ! ( range_inclusive( 0 i, 5 ) . collect:: <~[ int] >( ) , ~[ 0 i, 1 , 2 , 3 , 4 , 5 ] ) ;
2905
- assert_eq ! ( range_inclusive( 0 i, 5 ) . invert ( ) . collect:: <~[ int] >( ) , ~[ 5 i, 4 , 3 , 2 , 1 , 0 ] ) ;
2905
+ assert_eq ! ( range_inclusive( 0 i, 5 ) . rev ( ) . collect:: <~[ int] >( ) , ~[ 5 i, 4 , 3 , 2 , 1 , 0 ] ) ;
2906
2906
assert_eq ! ( range_inclusive( 200 , -5 ) . collect:: <~[ int] >( ) , ~[ ] ) ;
2907
- assert_eq ! ( range_inclusive( 200 , -5 ) . invert ( ) . collect:: <~[ int] >( ) , ~[ ] ) ;
2907
+ assert_eq ! ( range_inclusive( 200 , -5 ) . rev ( ) . collect:: <~[ int] >( ) , ~[ ] ) ;
2908
2908
assert_eq ! ( range_inclusive( 200 , 200 ) . collect:: <~[ int] >( ) , ~[ 200 ] ) ;
2909
- assert_eq ! ( range_inclusive( 200 , 200 ) . invert ( ) . collect:: <~[ int] >( ) , ~[ 200 ] ) ;
2909
+ assert_eq ! ( range_inclusive( 200 , 200 ) . rev ( ) . collect:: <~[ int] >( ) , ~[ 200 ] ) ;
2910
2910
}
2911
2911
2912
2912
#[ test]
0 commit comments