1
Fork 0

deque: Remove obsolete methods .each() and .eachi()

This commit is contained in:
blake2-ppc 2013-07-06 05:42:46 +02:00
parent 0ff5c17cbb
commit 07e2775dff
2 changed files with 1 additions and 30 deletions

View file

@ -77,16 +77,6 @@ impl<T> Deque<T> {
get(self.elts, idx)
}
/// Iterate over the elements in the deque
pub fn each(&self, f: &fn(&T) -> bool) -> bool {
self.eachi(|_i, e| f(e))
}
/// Iterate over the elements in the deque by index
pub fn eachi(&self, f: &fn(uint, &T) -> bool) -> bool {
uint::range(0, self.nelts, |i| f(i, self.get(i as int)))
}
/// Remove and return the first element in the deque
///
/// Fails if the deque is empty
@ -514,25 +504,6 @@ mod tests {
test_parameterized::<RecCy>(reccy1, reccy2, reccy3, reccy4);
}
#[test]
fn test_eachi() {
let mut deq = Deque::new();
deq.add_back(1);
deq.add_back(2);
deq.add_back(3);
for deq.eachi |i, e| {
assert_eq!(*e, i + 1);
}
deq.pop_front();
for deq.eachi |i, e| {
assert_eq!(*e, i + 2);
}
}
#[test]
fn test_with_capacity() {
let mut d = Deque::with_capacity(0);

View file

@ -682,7 +682,7 @@ impl<
> Encodable<S> for Deque<T> {
fn encode(&self, s: &mut S) {
do s.emit_seq(self.len()) |s| {
for self.eachi |i, e| {
for self.iter().enumerate().advance |(i, e)| {
s.emit_seq_elt(i, |s| e.encode(s));
}
}