mirror of
https://github.com/rust-lang/rust.git
synced 2025-05-09 16:37:36 +00:00
std: Remove uint::iterate, replaced by range
This commit is contained in:
parent
08d0b70213
commit
ea9c5c405e
@ -206,16 +206,15 @@ impl BigBitv {
|
|||||||
#[inline]
|
#[inline]
|
||||||
pub fn equals(&self, b: &BigBitv, nbits: uint) -> bool {
|
pub fn equals(&self, b: &BigBitv, nbits: uint) -> bool {
|
||||||
let len = b.storage.len();
|
let len = b.storage.len();
|
||||||
do uint::iterate(0, len) |i| {
|
for i in range(0, len) {
|
||||||
let mask = big_mask(nbits, i);
|
let mask = big_mask(nbits, i);
|
||||||
if mask & self.storage[i] != mask & b.storage[i] {
|
if mask & self.storage[i] != mask & b.storage[i] {
|
||||||
false
|
return false;
|
||||||
} else {
|
}
|
||||||
|
}
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[deriving(Clone)]
|
#[deriving(Clone)]
|
||||||
enum BitvVariant { Big(BigBitv), Small(SmallBitv) }
|
enum BitvVariant { Big(BigBitv), Small(SmallBitv) }
|
||||||
|
@ -70,30 +70,6 @@ pub fn div_round(x: uint, y: uint) -> uint {
|
|||||||
///
|
///
|
||||||
pub fn div_floor(x: uint, y: uint) -> uint { return x / y; }
|
pub fn div_floor(x: uint, y: uint) -> uint { return x / y; }
|
||||||
|
|
||||||
///
|
|
||||||
/// Iterate over the range [`lo`..`hi`), or stop when requested
|
|
||||||
///
|
|
||||||
/// # Arguments
|
|
||||||
///
|
|
||||||
/// * lo - The integer at which to start the loop (included)
|
|
||||||
/// * hi - The integer at which to stop the loop (excluded)
|
|
||||||
/// * it - A block to execute with each consecutive integer of the range.
|
|
||||||
/// Return `true` to continue, `false` to stop.
|
|
||||||
///
|
|
||||||
/// # Return value
|
|
||||||
///
|
|
||||||
/// `true` If execution proceeded correctly, `false` if it was interrupted,
|
|
||||||
/// that is if `it` returned `false` at any point.
|
|
||||||
///
|
|
||||||
pub fn iterate(lo: uint, hi: uint, it: &fn(uint) -> bool) -> bool {
|
|
||||||
let mut i = lo;
|
|
||||||
while i < hi {
|
|
||||||
if (!it(i)) { return false; }
|
|
||||||
i += 1u;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
impl iter::Times for uint {
|
impl iter::Times for uint {
|
||||||
#[inline]
|
#[inline]
|
||||||
///
|
///
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
|
|
||||||
use cast;
|
use cast;
|
||||||
use clone::Clone;
|
use clone::Clone;
|
||||||
|
use iterator::{range, Iterator};
|
||||||
use option::{Option, Some, None};
|
use option::{Option, Some, None};
|
||||||
use unstable::intrinsics;
|
use unstable::intrinsics;
|
||||||
use util::swap;
|
use util::swap;
|
||||||
@ -20,7 +21,6 @@ use util::swap;
|
|||||||
#[cfg(not(test))] use num::Int;
|
#[cfg(not(test))] use num::Int;
|
||||||
|
|
||||||
#[cfg(not(test))] use cmp::{Eq, Ord};
|
#[cfg(not(test))] use cmp::{Eq, Ord};
|
||||||
use uint;
|
|
||||||
|
|
||||||
/// Calculate the offset from a pointer
|
/// Calculate the offset from a pointer
|
||||||
#[inline]
|
#[inline]
|
||||||
@ -240,11 +240,10 @@ pub unsafe fn array_each_with_len<T>(arr: **T, len: uint, cb: &fn(*T)) {
|
|||||||
fail!("ptr::array_each_with_len failure: arr input is null pointer");
|
fail!("ptr::array_each_with_len failure: arr input is null pointer");
|
||||||
}
|
}
|
||||||
//let start_ptr = *arr;
|
//let start_ptr = *arr;
|
||||||
uint::iterate(0, len, |e| {
|
for e in range(0, len) {
|
||||||
let n = offset(arr, e as int);
|
let n = offset(arr, e as int);
|
||||||
cb(*n);
|
cb(*n);
|
||||||
true
|
}
|
||||||
});
|
|
||||||
debug!("array_each_with_len: after iterate");
|
debug!("array_each_with_len: after iterate");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user