Skip to content

Commit 5d46bcc

Browse files
committed
Remove vec::{rfind, rfind_between, find_between}, replaced by slices and iterator adapators.
1 parent 6fcd8bf commit 5d46bcc

File tree

2 files changed

+1
-120
lines changed

2 files changed

+1
-120
lines changed

src/librustc/middle/trans/base.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1263,7 +1263,7 @@ pub fn cleanup_and_leave(bcx: block,
12631263
let mut skip = 0;
12641264
let mut dest = None;
12651265
{
1266-
let r = vec::rfind((*inf).cleanup_paths, |cp| cp.target == leave);
1266+
let r = (*inf).cleanup_paths.rev_iter().find_(|cp| cp.target == leave);
12671267
for r.iter().advance |cp| {
12681268
if cp.size == inf.cleanups.len() {
12691269
Br(bcx, cp.dest);

src/libstd/vec.rs

Lines changed: 0 additions & 119 deletions
Original file line numberDiff line numberDiff line change
@@ -652,44 +652,6 @@ pub fn contains<T:Eq>(v: &[T], x: &T) -> bool {
652652
false
653653
}
654654

655-
/**
656-
* Search for the first element that matches a given predicate within a range
657-
*
658-
* Apply function `f` to each element of `v` within the range
659-
* [`start`, `end`). When function `f` returns true then an option containing
660-
* the element is returned. If `f` matches no elements then none is returned.
661-
*/
662-
pub fn find_between<T:Copy>(v: &[T], start: uint, end: uint,
663-
f: &fn(t: &T) -> bool) -> Option<T> {
664-
position_between(v, start, end, f).map(|i| copy v[*i])
665-
}
666-
667-
/**
668-
* Search for the last element that matches a given predicate
669-
*
670-
* Apply function `f` to each element of `v` in reverse order. When function
671-
* `f` returns true then an option containing the element is returned. If `f`
672-
* matches no elements then none is returned.
673-
*/
674-
pub fn rfind<T:Copy>(v: &[T], f: &fn(t: &T) -> bool) -> Option<T> {
675-
rfind_between(v, 0u, v.len(), f)
676-
}
677-
678-
/**
679-
* Search for the last element that matches a given predicate within a range
680-
*
681-
* Apply function `f` to each element of `v` in reverse order within the range
682-
* [`start`, `end`). When function `f` returns true then an option containing
683-
* the element is returned. If `f` matches no elements then none is return.
684-
*/
685-
pub fn rfind_between<T:Copy>(v: &[T],
686-
start: uint,
687-
end: uint,
688-
f: &fn(t: &T) -> bool)
689-
-> Option<T> {
690-
rposition_between(v, start, end, f).map(|i| copy v[*i])
691-
}
692-
693655
/// Find the first index containing a matching value
694656
pub fn position_elem<T:Eq>(v: &[T], x: &T) -> Option<uint> {
695657
v.iter().position_(|y| *x == *y)
@@ -1422,7 +1384,6 @@ impl<'self,T:Eq> ImmutableEqVector<T> for &'self [T] {
14221384
#[allow(missing_doc)]
14231385
pub trait ImmutableCopyableVector<T> {
14241386
fn filtered(&self, f: &fn(&T) -> bool) -> ~[T];
1425-
fn rfind(&self, f: &fn(t: &T) -> bool) -> Option<T>;
14261387
fn partitioned(&self, f: &fn(&T) -> bool) -> (~[T], ~[T]);
14271388
unsafe fn unsafe_get(&self, elem: uint) -> T;
14281389
}
@@ -1441,18 +1402,6 @@ impl<'self,T:Copy> ImmutableCopyableVector<T> for &'self [T] {
14411402
filtered(*self, f)
14421403
}
14431404

1444-
/**
1445-
* Search for the last element that matches a given predicate
1446-
*
1447-
* Apply function `f` to each element of `v` in reverse order. When
1448-
* function `f` returns true then an option containing the element is
1449-
* returned. If `f` matches no elements then none is returned.
1450-
*/
1451-
#[inline]
1452-
fn rfind(&self, f: &fn(t: &T) -> bool) -> Option<T> {
1453-
rfind(*self, f)
1454-
}
1455-
14561405
/**
14571406
* Partitions the vector into those that satisfies the predicate, and
14581407
* those that do not.
@@ -2964,34 +2913,6 @@ mod tests {
29642913
assert!(position_between(v, 4u, 4u, f).is_none());
29652914
}
29662915

2967-
#[test]
2968-
fn test_find_between() {
2969-
assert!(find_between([], 0u, 0u, f).is_none());
2970-
2971-
fn f(xy: &(int, char)) -> bool { let (_x, y) = *xy; y == 'b' }
2972-
let v = ~[(0, 'a'), (1, 'b'), (2, 'c'), (3, 'b')];
2973-
2974-
assert!(find_between(v, 0u, 0u, f).is_none());
2975-
assert!(find_between(v, 0u, 1u, f).is_none());
2976-
assert_eq!(find_between(v, 0u, 2u, f), Some((1, 'b')));
2977-
assert_eq!(find_between(v, 0u, 3u, f), Some((1, 'b')));
2978-
assert_eq!(find_between(v, 0u, 4u, f), Some((1, 'b')));
2979-
2980-
assert!(find_between(v, 1u, 1u, f).is_none());
2981-
assert_eq!(find_between(v, 1u, 2u, f), Some((1, 'b')));
2982-
assert_eq!(find_between(v, 1u, 3u, f), Some((1, 'b')));
2983-
assert_eq!(find_between(v, 1u, 4u, f), Some((1, 'b')));
2984-
2985-
assert!(find_between(v, 2u, 2u, f).is_none());
2986-
assert!(find_between(v, 2u, 3u, f).is_none());
2987-
assert_eq!(find_between(v, 2u, 4u, f), Some((3, 'b')));
2988-
2989-
assert!(find_between(v, 3u, 3u, f).is_none());
2990-
assert_eq!(find_between(v, 3u, 4u, f), Some((3, 'b')));
2991-
2992-
assert!(find_between(v, 4u, 4u, f).is_none());
2993-
}
2994-
29952916
#[test]
29962917
fn test_rposition() {
29972918
fn f(xy: &(int, char)) -> bool { let (_x, y) = *xy; y == 'b' }
@@ -3030,46 +2951,6 @@ mod tests {
30302951
assert!(rposition_between(v, 4u, 4u, f).is_none());
30312952
}
30322953

3033-
#[test]
3034-
fn test_rfind() {
3035-
assert!(rfind([], f).is_none());
3036-
3037-
fn f(xy: &(int, char)) -> bool { let (_x, y) = *xy; y == 'b' }
3038-
fn g(xy: &(int, char)) -> bool { let (_x, y) = *xy; y == 'd' }
3039-
let v = ~[(0, 'a'), (1, 'b'), (2, 'c'), (3, 'b')];
3040-
3041-
assert_eq!(rfind(v, f), Some((3, 'b')));
3042-
assert!(rfind(v, g).is_none());
3043-
}
3044-
3045-
#[test]
3046-
fn test_rfind_between() {
3047-
assert!(rfind_between([], 0u, 0u, f).is_none());
3048-
3049-
fn f(xy: &(int, char)) -> bool { let (_x, y) = *xy; y == 'b' }
3050-
let v = ~[(0, 'a'), (1, 'b'), (2, 'c'), (3, 'b')];
3051-
3052-
assert!(rfind_between(v, 0u, 0u, f).is_none());
3053-
assert!(rfind_between(v, 0u, 1u, f).is_none());
3054-
assert_eq!(rfind_between(v, 0u, 2u, f), Some((1, 'b')));
3055-
assert_eq!(rfind_between(v, 0u, 3u, f), Some((1, 'b')));
3056-
assert_eq!(rfind_between(v, 0u, 4u, f), Some((3, 'b')));
3057-
3058-
assert!(rfind_between(v, 1u, 1u, f).is_none());
3059-
assert_eq!(rfind_between(v, 1u, 2u, f), Some((1, 'b')));
3060-
assert_eq!(rfind_between(v, 1u, 3u, f), Some((1, 'b')));
3061-
assert_eq!(rfind_between(v, 1u, 4u, f), Some((3, 'b')));
3062-
3063-
assert!(rfind_between(v, 2u, 2u, f).is_none());
3064-
assert!(rfind_between(v, 2u, 3u, f).is_none());
3065-
assert_eq!(rfind_between(v, 2u, 4u, f), Some((3, 'b')));
3066-
3067-
assert!(rfind_between(v, 3u, 3u, f).is_none());
3068-
assert_eq!(rfind_between(v, 3u, 4u, f), Some((3, 'b')));
3069-
3070-
assert!(rfind_between(v, 4u, 4u, f).is_none());
3071-
}
3072-
30732954
#[test]
30742955
fn test_bsearch_elem() {
30752956
assert_eq!(bsearch_elem([1,2,3,4,5], &5), Some(4));

0 commit comments

Comments
 (0)