@@ -2283,21 +2283,21 @@ impl<T, A: Allocator> VecDeque<T, A> {
2283
2283
unsafe { slice:: from_raw_parts_mut ( ptr. add ( self . head ) , self . len ) }
2284
2284
}
2285
2285
2286
- /// Rotates the double-ended queue `mid ` places to the left.
2286
+ /// Rotates the double-ended queue `n ` places to the left.
2287
2287
///
2288
2288
/// Equivalently,
2289
- /// - Rotates item `mid ` into the first position.
2290
- /// - Pops the first `mid ` items and pushes them to the end.
2291
- /// - Rotates `len() - mid ` places to the right.
2289
+ /// - Rotates item `n ` into the first position.
2290
+ /// - Pops the first `n ` items and pushes them to the end.
2291
+ /// - Rotates `len() - n ` places to the right.
2292
2292
///
2293
2293
/// # Panics
2294
2294
///
2295
- /// If `mid ` is greater than `len()`. Note that `mid == len()`
2295
+ /// If `n ` is greater than `len()`. Note that `n == len()`
2296
2296
/// does _not_ panic and is a no-op rotation.
2297
2297
///
2298
2298
/// # Complexity
2299
2299
///
2300
- /// Takes `*O*(min(mid , len() - mid ))` time and no extra space.
2300
+ /// Takes `*O*(min(n , len() - n ))` time and no extra space.
2301
2301
///
2302
2302
/// # Examples
2303
2303
///
@@ -2316,31 +2316,31 @@ impl<T, A: Allocator> VecDeque<T, A> {
2316
2316
/// assert_eq!(buf, [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]);
2317
2317
/// ```
2318
2318
#[ stable( feature = "vecdeque_rotate" , since = "1.36.0" ) ]
2319
- pub fn rotate_left ( & mut self , mid : usize ) {
2320
- assert ! ( mid <= self . len( ) ) ;
2321
- let k = self . len - mid ;
2322
- if mid <= k {
2323
- unsafe { self . rotate_left_inner ( mid ) }
2319
+ pub fn rotate_left ( & mut self , n : usize ) {
2320
+ assert ! ( n <= self . len( ) ) ;
2321
+ let k = self . len - n ;
2322
+ if n <= k {
2323
+ unsafe { self . rotate_left_inner ( n ) }
2324
2324
} else {
2325
2325
unsafe { self . rotate_right_inner ( k) }
2326
2326
}
2327
2327
}
2328
2328
2329
- /// Rotates the double-ended queue `k ` places to the right.
2329
+ /// Rotates the double-ended queue `n ` places to the right.
2330
2330
///
2331
2331
/// Equivalently,
2332
- /// - Rotates the first item into position `k `.
2333
- /// - Pops the last `k ` items and pushes them to the front.
2334
- /// - Rotates `len() - k ` places to the left.
2332
+ /// - Rotates the first item into position `n `.
2333
+ /// - Pops the last `n ` items and pushes them to the front.
2334
+ /// - Rotates `len() - n ` places to the left.
2335
2335
///
2336
2336
/// # Panics
2337
2337
///
2338
- /// If `k ` is greater than `len()`. Note that `k == len()`
2338
+ /// If `n ` is greater than `len()`. Note that `n == len()`
2339
2339
/// does _not_ panic and is a no-op rotation.
2340
2340
///
2341
2341
/// # Complexity
2342
2342
///
2343
- /// Takes `*O*(min(k , len() - k ))` time and no extra space.
2343
+ /// Takes `*O*(min(n , len() - n ))` time and no extra space.
2344
2344
///
2345
2345
/// # Examples
2346
2346
///
@@ -2359,13 +2359,13 @@ impl<T, A: Allocator> VecDeque<T, A> {
2359
2359
/// assert_eq!(buf, [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]);
2360
2360
/// ```
2361
2361
#[ stable( feature = "vecdeque_rotate" , since = "1.36.0" ) ]
2362
- pub fn rotate_right ( & mut self , k : usize ) {
2363
- assert ! ( k <= self . len( ) ) ;
2364
- let mid = self . len - k ;
2365
- if k <= mid {
2366
- unsafe { self . rotate_right_inner ( k ) }
2362
+ pub fn rotate_right ( & mut self , n : usize ) {
2363
+ assert ! ( n <= self . len( ) ) ;
2364
+ let k = self . len - n ;
2365
+ if n <= k {
2366
+ unsafe { self . rotate_right_inner ( n ) }
2367
2367
} else {
2368
- unsafe { self . rotate_left_inner ( mid ) }
2368
+ unsafe { self . rotate_left_inner ( k ) }
2369
2369
}
2370
2370
}
2371
2371
0 commit comments