use core::ptr;
use core::iter::{range_step, MultiplicativeIterator};
-use Collection;
+use {Collection, MutableSeq};
use vec::Vec;
pub use core::slice::{ref_slice, mut_ref_slice, Splits, Windows};
/// a sequence of all possible permutations for an indexed sequence of
/// elements. Each permutation is only a single swap apart.
///
-/// The Steinhaus–Johnson–Trotter algorithm is used.
+/// The Steinhaus-Johnson-Trotter algorithm is used.
///
/// Generates even and odd permutations alternately.
///
/// Extension methods for vector slices with cloneable elements
pub trait CloneableVector<T> {
- /// Copy `self` into a new owned vector
- fn to_owned(&self) -> Vec<T>;
+ /// Copy `self` into a new vector
+ fn to_vec(&self) -> Vec<T>;
+
+ /// Deprecated. Use `to_vec`
+ #[deprecated = "Replaced by `to_vec`"]
+ fn to_owned(&self) -> Vec<T> {
+ self.to_vec()
+ }
/// Convert `self` into an owned vector, not making a copy if possible.
- fn into_owned(self) -> Vec<T>;
+ fn into_vec(self) -> Vec<T>;
+
+ /// Deprecated. Use `into_vec`
+ #[deprecated = "Replaced by `into_vec`"]
+ fn into_owned(self) -> Vec<T> {
+ self.into_vec()
+ }
}
/// Extension methods for vector slices
impl<'a, T: Clone> CloneableVector<T> for &'a [T] {
/// Returns a copy of `v`.
#[inline]
- fn to_owned(&self) -> Vec<T> { Vec::from_slice(*self) }
+ fn to_vec(&self) -> Vec<T> { Vec::from_slice(*self) }
#[inline(always)]
- fn into_owned(self) -> Vec<T> { self.to_owned() }
+ fn into_vec(self) -> Vec<T> { self.to_vec() }
}
/// Extension methods for vectors containing `Clone` elements.
fn permutations(self) -> Permutations<T> {
Permutations{
swaps: ElementSwaps::new(self.len()),
- v: self.to_owned(),
+ v: self.to_vec(),
}
}
*
* * src - A mutable vector of `T`
* * start - The index into `src` to start copying from
- * * end - The index into `str` to stop copying from
+ * * end - The index into `src` to stop copying from
*/
fn move_from(self, src: Vec<T>, start: uint, end: uint) -> uint;
}
use std::rt;
use slice::*;
- use Mutable;
+ use {Mutable, MutableSeq};
use vec::Vec;
fn square(n: uint) -> uint { n * n }
fn test_slice() {
// Test fixed length vector.
let vec_fixed = [1i, 2, 3, 4];
- let v_a = vec_fixed.slice(1u, vec_fixed.len()).to_owned();
+ let v_a = vec_fixed.slice(1u, vec_fixed.len()).to_vec();
assert_eq!(v_a.len(), 3u);
let v_a = v_a.as_slice();
assert_eq!(v_a[0], 2);
// Test on stack.
let vec_stack = &[1i, 2, 3];
- let v_b = vec_stack.slice(1u, 3u).to_owned();
+ let v_b = vec_stack.slice(1u, 3u).to_vec();
assert_eq!(v_b.len(), 2u);
let v_b = v_b.as_slice();
assert_eq!(v_b[0], 2);
// Test `Box<[T]>`
let vec_unique = vec![1i, 2, 3, 4, 5, 6];
- let v_d = vec_unique.slice(1u, 6u).to_owned();
+ let v_d = vec_unique.slice(1u, 6u).to_vec();
assert_eq!(v_d.len(), 5u);
let v_d = v_d.as_slice();
assert_eq!(v_d[0], 2);
let (min_size, max_opt) = it.size_hint();
assert_eq!(min_size, 1);
assert_eq!(max_opt.unwrap(), 1);
- assert_eq!(it.next(), Some(v.as_slice().to_owned()));
+ assert_eq!(it.next(), Some(v.as_slice().to_vec()));
assert_eq!(it.next(), None);
}
{
let (min_size, max_opt) = it.size_hint();
assert_eq!(min_size, 1);
assert_eq!(max_opt.unwrap(), 1);
- assert_eq!(it.next(), Some(v.as_slice().to_owned()));
+ assert_eq!(it.next(), Some(v.as_slice().to_vec()));
assert_eq!(it.next(), None);
}
{
use test::Bencher;
use vec::Vec;
+ use MutableSeq;
#[bench]
fn iterator(b: &mut Bencher) {