@@ -108,8 +108,8 @@ impl<T> VecDeque<T> {
108
108
109
109
/// Writes an element into the buffer, moving it.
110
110
#[ inline]
111
- unsafe fn buffer_write ( & mut self , off : usize , t : T ) {
112
- ptr:: write ( self . ptr ( ) . offset ( off as isize ) , t ) ;
111
+ unsafe fn buffer_write ( & mut self , off : usize , value : T ) {
112
+ ptr:: write ( self . ptr ( ) . offset ( off as isize ) , value ) ;
113
113
}
114
114
115
115
/// Returns true if and only if the buffer is at capacity
@@ -234,9 +234,9 @@ impl<T> VecDeque<T> {
234
234
/// assert_eq!(buf.get(1).unwrap(), &4);
235
235
/// ```
236
236
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
237
- pub fn get ( & self , i : usize ) -> Option < & T > {
238
- if i < self . len ( ) {
239
- let idx = self . wrap_add ( self . tail , i ) ;
237
+ pub fn get ( & self , index : usize ) -> Option < & T > {
238
+ if index < self . len ( ) {
239
+ let idx = self . wrap_add ( self . tail , index ) ;
240
240
unsafe { Some ( & * self . ptr ( ) . offset ( idx as isize ) ) }
241
241
} else {
242
242
None
@@ -261,9 +261,9 @@ impl<T> VecDeque<T> {
261
261
/// assert_eq!(buf[1], 7);
262
262
/// ```
263
263
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
264
- pub fn get_mut ( & mut self , i : usize ) -> Option < & mut T > {
265
- if i < self . len ( ) {
266
- let idx = self . wrap_add ( self . tail , i ) ;
264
+ pub fn get_mut ( & mut self , index : usize ) -> Option < & mut T > {
265
+ if index < self . len ( ) {
266
+ let idx = self . wrap_add ( self . tail , index ) ;
267
267
unsafe { Some ( & mut * self . ptr ( ) . offset ( idx as isize ) ) }
268
268
} else {
269
269
None
@@ -768,7 +768,7 @@ impl<T> VecDeque<T> {
768
768
/// assert_eq!(d.front(), Some(&2));
769
769
/// ```
770
770
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
771
- pub fn push_front ( & mut self , t : T ) {
771
+ pub fn push_front ( & mut self , value : T ) {
772
772
if self . is_full ( ) {
773
773
let old_cap = self . cap ( ) ;
774
774
self . buf . double ( ) ;
@@ -778,7 +778,7 @@ impl<T> VecDeque<T> {
778
778
779
779
self . tail = self . wrap_sub ( self . tail , 1 ) ;
780
780
let tail = self . tail ;
781
- unsafe { self . buffer_write ( tail, t ) ; }
781
+ unsafe { self . buffer_write ( tail, value ) ; }
782
782
}
783
783
784
784
/// Appends an element to the back of a buffer
@@ -794,7 +794,7 @@ impl<T> VecDeque<T> {
794
794
/// assert_eq!(3, *buf.back().unwrap());
795
795
/// ```
796
796
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
797
- pub fn push_back ( & mut self , t : T ) {
797
+ pub fn push_back ( & mut self , value : T ) {
798
798
if self . is_full ( ) {
799
799
let old_cap = self . cap ( ) ;
800
800
self . buf . double ( ) ;
@@ -804,7 +804,7 @@ impl<T> VecDeque<T> {
804
804
805
805
let head = self . head ;
806
806
self . head = self . wrap_add ( self . head , 1 ) ;
807
- unsafe { self . buffer_write ( head, t ) }
807
+ unsafe { self . buffer_write ( head, value ) }
808
808
}
809
809
810
810
/// Removes the last element from a buffer and returns it, or `None` if
@@ -905,13 +905,13 @@ impl<T> VecDeque<T> {
905
905
self . pop_front ( )
906
906
}
907
907
908
- /// Inserts an element at position `i ` within the `VecDeque`. Whichever
908
+ /// Inserts an element at `index ` within the `VecDeque`. Whichever
909
909
/// end is closer to the insertion point will be moved to make room,
910
910
/// and all the affected elements will be moved to new positions.
911
911
///
912
912
/// # Panics
913
913
///
914
- /// Panics if `i ` is greater than `VecDeque`'s length
914
+ /// Panics if `index ` is greater than `VecDeque`'s length
915
915
///
916
916
/// # Examples
917
917
/// ```
@@ -924,8 +924,8 @@ impl<T> VecDeque<T> {
924
924
/// buf.insert(1, 11);
925
925
/// assert_eq!(Some(&11), buf.get(1));
926
926
/// ```
927
- pub fn insert ( & mut self , i : usize , t : T ) {
928
- assert ! ( i <= self . len( ) , "index out of bounds" ) ;
927
+ pub fn insert ( & mut self , index : usize , value : T ) {
928
+ assert ! ( index <= self . len( ) , "index out of bounds" ) ;
929
929
if self . is_full ( ) {
930
930
let old_cap = self . cap ( ) ;
931
931
self . buf . double ( ) ;
@@ -955,15 +955,15 @@ impl<T> VecDeque<T> {
955
955
// A - The element that should be after the insertion point
956
956
// M - Indicates element was moved
957
957
958
- let idx = self . wrap_add ( self . tail , i ) ;
958
+ let idx = self . wrap_add ( self . tail , index ) ;
959
959
960
- let distance_to_tail = i ;
961
- let distance_to_head = self . len ( ) - i ;
960
+ let distance_to_tail = index ;
961
+ let distance_to_head = self . len ( ) - index ;
962
962
963
963
let contiguous = self . is_contiguous ( ) ;
964
964
965
965
match ( contiguous, distance_to_tail <= distance_to_head, idx >= self . tail ) {
966
- ( true , true , _) if i == 0 => {
966
+ ( true , true , _) if index == 0 => {
967
967
// push_front
968
968
//
969
969
// T
@@ -999,8 +999,8 @@ impl<T> VecDeque<T> {
999
999
let new_tail = self . wrap_sub ( self . tail , 1 ) ;
1000
1000
1001
1001
self . copy ( new_tail, self . tail , 1 ) ;
1002
- // Already moved the tail, so we only copy `i - 1` elements.
1003
- self . copy ( self . tail , self . tail + 1 , i - 1 ) ;
1002
+ // Already moved the tail, so we only copy `index - 1` elements.
1003
+ self . copy ( self . tail , self . tail + 1 , index - 1 ) ;
1004
1004
1005
1005
self . tail = new_tail;
1006
1006
} ,
@@ -1027,7 +1027,7 @@ impl<T> VecDeque<T> {
1027
1027
// [o o o o o o . . . . o o I A o o]
1028
1028
// M M
1029
1029
1030
- self . copy ( self . tail - 1 , self . tail , i ) ;
1030
+ self . copy ( self . tail - 1 , self . tail , index ) ;
1031
1031
self . tail -= 1 ;
1032
1032
} ,
1033
1033
( false , false , true ) => unsafe {
@@ -1107,16 +1107,16 @@ impl<T> VecDeque<T> {
1107
1107
}
1108
1108
1109
1109
// tail might've been changed so we need to recalculate
1110
- let new_idx = self . wrap_add ( self . tail , i ) ;
1110
+ let new_idx = self . wrap_add ( self . tail , index ) ;
1111
1111
unsafe {
1112
- self . buffer_write ( new_idx, t ) ;
1112
+ self . buffer_write ( new_idx, value ) ;
1113
1113
}
1114
1114
}
1115
1115
1116
- /// Removes and returns the element at position `i ` from the `VecDeque`.
1116
+ /// Removes and returns the element at `index ` from the `VecDeque`.
1117
1117
/// Whichever end is closer to the removal point will be moved to make
1118
1118
/// room, and all the affected elements will be moved to new positions.
1119
- /// Returns `None` if `i ` is out of bounds.
1119
+ /// Returns `None` if `index ` is out of bounds.
1120
1120
///
1121
1121
/// # Examples
1122
1122
/// ```
@@ -1131,8 +1131,8 @@ impl<T> VecDeque<T> {
1131
1131
/// assert_eq!(Some(&15), buf.get(2));
1132
1132
/// ```
1133
1133
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
1134
- pub fn remove ( & mut self , i : usize ) -> Option < T > {
1135
- if self . is_empty ( ) || self . len ( ) <= i {
1134
+ pub fn remove ( & mut self , index : usize ) -> Option < T > {
1135
+ if self . is_empty ( ) || self . len ( ) <= index {
1136
1136
return None ;
1137
1137
}
1138
1138
@@ -1154,14 +1154,14 @@ impl<T> VecDeque<T> {
1154
1154
// R - Indicates element that is being removed
1155
1155
// M - Indicates element was moved
1156
1156
1157
- let idx = self . wrap_add ( self . tail , i ) ;
1157
+ let idx = self . wrap_add ( self . tail , index ) ;
1158
1158
1159
1159
let elem = unsafe {
1160
1160
Some ( self . buffer_read ( idx) )
1161
1161
} ;
1162
1162
1163
- let distance_to_tail = i ;
1164
- let distance_to_head = self . len ( ) - i ;
1163
+ let distance_to_tail = index ;
1164
+ let distance_to_head = self . len ( ) - index ;
1165
1165
1166
1166
let contiguous = self . is_contiguous ( ) ;
1167
1167
@@ -1176,7 +1176,7 @@ impl<T> VecDeque<T> {
1176
1176
// [. . . . o o o o o o . . . . . .]
1177
1177
// M M
1178
1178
1179
- self . copy ( self . tail + 1 , self . tail , i ) ;
1179
+ self . copy ( self . tail + 1 , self . tail , index ) ;
1180
1180
self . tail += 1 ;
1181
1181
} ,
1182
1182
( true , false , _) => unsafe {
@@ -1202,7 +1202,7 @@ impl<T> VecDeque<T> {
1202
1202
// [o o o o o o . . . . . . o o o o]
1203
1203
// M M
1204
1204
1205
- self . copy ( self . tail + 1 , self . tail , i ) ;
1205
+ self . copy ( self . tail + 1 , self . tail , index ) ;
1206
1206
self . tail = self . wrap_add ( self . tail , 1 ) ;
1207
1207
} ,
1208
1208
( false , false , false ) => unsafe {
@@ -1700,16 +1700,16 @@ impl<A> Index<usize> for VecDeque<A> {
1700
1700
type Output = A ;
1701
1701
1702
1702
#[ inline]
1703
- fn index ( & self , i : usize ) -> & A {
1704
- self . get ( i ) . expect ( "Out of bounds access" )
1703
+ fn index ( & self , index : usize ) -> & A {
1704
+ self . get ( index ) . expect ( "Out of bounds access" )
1705
1705
}
1706
1706
}
1707
1707
1708
1708
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
1709
1709
impl < A > IndexMut < usize > for VecDeque < A > {
1710
1710
#[ inline]
1711
- fn index_mut ( & mut self , i : usize ) -> & mut A {
1712
- self . get_mut ( i ) . expect ( "Out of bounds access" )
1711
+ fn index_mut ( & mut self , index : usize ) -> & mut A {
1712
+ self . get_mut ( index ) . expect ( "Out of bounds access" )
1713
1713
}
1714
1714
}
1715
1715
0 commit comments