1
Fork 0

std: remove vec::each2 and vec::each2_mut in favour of iterators

This commit is contained in:
Huon Wilson 2013-06-08 01:20:47 +10:00
parent 5e9f006c5b
commit f661a15b2b
10 changed files with 24 additions and 97 deletions

View file

@ -1666,44 +1666,6 @@ pub fn eachi_reverse<'r,T>(v: &'r [T],
return true;
}
/**
* Iterates over two vectors simultaneously
*
* # Failure
*
* Both vectors must have the same length
*/
#[inline]
pub fn each2<U, T>(v1: &[U], v2: &[T], f: &fn(u: &U, t: &T) -> bool) -> bool {
assert_eq!(v1.len(), v2.len());
for uint::range(0u, v1.len()) |i| {
if !f(&v1[i], &v2[i]) {
return false;
}
}
return true;
}
/**
*
* Iterates over two vector with mutable.
*
* # Failure
*
* Both vectors must have the same length
*/
#[inline]
pub fn each2_mut<U, T>(v1: &mut [U], v2: &mut [T],
f: &fn(u: &mut U, t: &mut T) -> bool) -> bool {
assert_eq!(v1.len(), v2.len());
for uint::range(0u, v1.len()) |i| {
if !f(&mut v1[i], &mut v2[i]) {
return false;
}
}
return true;
}
/**
* Iterate over all permutations of vector `v`.
*