mirror of
https://github.com/rust-lang/rust.git
synced 2025-05-14 02:49:40 +00:00
remove int_uint feature from libcollections
This commit is contained in:
parent
1420cebebd
commit
15fb06d730
@ -266,8 +266,8 @@ impl Bitv {
|
||||
/// ```
|
||||
/// use std::collections::Bitv;
|
||||
///
|
||||
/// let mut bv = Bitv::from_elem(10u, false);
|
||||
/// assert_eq!(bv.len(), 10u);
|
||||
/// let mut bv = Bitv::from_elem(10, false);
|
||||
/// assert_eq!(bv.len(), 10);
|
||||
/// for x in bv.iter() {
|
||||
/// assert_eq!(x, false);
|
||||
/// }
|
||||
@ -353,7 +353,7 @@ impl Bitv {
|
||||
/// ```
|
||||
pub fn from_fn<F>(len: usize, mut f: F) -> Bitv where F: FnMut(usize) -> bool {
|
||||
let mut bitv = Bitv::from_elem(len, false);
|
||||
for i in 0u..len {
|
||||
for i in 0..len {
|
||||
bitv.set(i, f(i));
|
||||
}
|
||||
bitv
|
||||
@ -1415,7 +1415,7 @@ impl BitvSet {
|
||||
#[inline]
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
pub fn iter(&self) -> bitv_set::Iter {
|
||||
SetIter {set: self, next_idx: 0u}
|
||||
SetIter {set: self, next_idx: 0}
|
||||
}
|
||||
|
||||
/// Iterator over each u32 stored in `self` union `other`.
|
||||
@ -1443,8 +1443,8 @@ impl BitvSet {
|
||||
set: self,
|
||||
other: other,
|
||||
merge: or,
|
||||
current_word: 0u32,
|
||||
next_idx: 0u
|
||||
current_word: 0,
|
||||
next_idx: 0
|
||||
})
|
||||
}
|
||||
|
||||
@ -1473,7 +1473,7 @@ impl BitvSet {
|
||||
set: self,
|
||||
other: other,
|
||||
merge: bitand,
|
||||
current_word: 0u32,
|
||||
current_word: 0,
|
||||
next_idx: 0
|
||||
}.take(min))
|
||||
}
|
||||
@ -1510,7 +1510,7 @@ impl BitvSet {
|
||||
set: self,
|
||||
other: other,
|
||||
merge: diff,
|
||||
current_word: 0u32,
|
||||
current_word: 0,
|
||||
next_idx: 0
|
||||
})
|
||||
}
|
||||
@ -1541,7 +1541,7 @@ impl BitvSet {
|
||||
set: self,
|
||||
other: other,
|
||||
merge: bitxor,
|
||||
current_word: 0u32,
|
||||
current_word: 0,
|
||||
next_idx: 0
|
||||
})
|
||||
}
|
||||
@ -1902,7 +1902,7 @@ mod tests {
|
||||
let zerolen = Bitv::new();
|
||||
assert_eq!(format!("{:?}", zerolen), "");
|
||||
|
||||
let eightbits = Bitv::from_elem(8u, false);
|
||||
let eightbits = Bitv::from_elem(8, false);
|
||||
assert_eq!(format!("{:?}", eightbits), "00000000")
|
||||
}
|
||||
|
||||
@ -1916,10 +1916,10 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_1_element() {
|
||||
let mut act = Bitv::from_elem(1u, false);
|
||||
let mut act = Bitv::from_elem(1, false);
|
||||
assert!(act.eq_vec(&[false]));
|
||||
assert!(act.none() && !act.all());
|
||||
act = Bitv::from_elem(1u, true);
|
||||
act = Bitv::from_elem(1, true);
|
||||
assert!(act.eq_vec(&[true]));
|
||||
assert!(!act.none() && act.all());
|
||||
}
|
||||
@ -1938,42 +1938,42 @@ mod tests {
|
||||
let mut act;
|
||||
// all 0
|
||||
|
||||
act = Bitv::from_elem(10u, false);
|
||||
act = Bitv::from_elem(10, false);
|
||||
assert!((act.eq_vec(
|
||||
&[false, false, false, false, false, false, false, false, false, false])));
|
||||
assert!(act.none() && !act.all());
|
||||
// all 1
|
||||
|
||||
act = Bitv::from_elem(10u, true);
|
||||
act = Bitv::from_elem(10, true);
|
||||
assert!((act.eq_vec(&[true, true, true, true, true, true, true, true, true, true])));
|
||||
assert!(!act.none() && act.all());
|
||||
// mixed
|
||||
|
||||
act = Bitv::from_elem(10u, false);
|
||||
act.set(0u, true);
|
||||
act.set(1u, true);
|
||||
act.set(2u, true);
|
||||
act.set(3u, true);
|
||||
act.set(4u, true);
|
||||
act = Bitv::from_elem(10, false);
|
||||
act.set(0, true);
|
||||
act.set(1, true);
|
||||
act.set(2, true);
|
||||
act.set(3, true);
|
||||
act.set(4, true);
|
||||
assert!((act.eq_vec(&[true, true, true, true, true, false, false, false, false, false])));
|
||||
assert!(!act.none() && !act.all());
|
||||
// mixed
|
||||
|
||||
act = Bitv::from_elem(10u, false);
|
||||
act.set(5u, true);
|
||||
act.set(6u, true);
|
||||
act.set(7u, true);
|
||||
act.set(8u, true);
|
||||
act.set(9u, true);
|
||||
act = Bitv::from_elem(10, false);
|
||||
act.set(5, true);
|
||||
act.set(6, true);
|
||||
act.set(7, true);
|
||||
act.set(8, true);
|
||||
act.set(9, true);
|
||||
assert!((act.eq_vec(&[false, false, false, false, false, true, true, true, true, true])));
|
||||
assert!(!act.none() && !act.all());
|
||||
// mixed
|
||||
|
||||
act = Bitv::from_elem(10u, false);
|
||||
act.set(0u, true);
|
||||
act.set(3u, true);
|
||||
act.set(6u, true);
|
||||
act.set(9u, true);
|
||||
act = Bitv::from_elem(10, false);
|
||||
act.set(0, true);
|
||||
act.set(3, true);
|
||||
act.set(6, true);
|
||||
act.set(9, true);
|
||||
assert!((act.eq_vec(&[true, false, false, true, false, false, true, false, false, true])));
|
||||
assert!(!act.none() && !act.all());
|
||||
}
|
||||
@ -1983,7 +1983,7 @@ mod tests {
|
||||
let mut act;
|
||||
// all 0
|
||||
|
||||
act = Bitv::from_elem(31u, false);
|
||||
act = Bitv::from_elem(31, false);
|
||||
assert!(act.eq_vec(
|
||||
&[false, false, false, false, false, false, false, false, false, false, false,
|
||||
false, false, false, false, false, false, false, false, false, false, false,
|
||||
@ -1991,7 +1991,7 @@ mod tests {
|
||||
assert!(act.none() && !act.all());
|
||||
// all 1
|
||||
|
||||
act = Bitv::from_elem(31u, true);
|
||||
act = Bitv::from_elem(31, true);
|
||||
assert!(act.eq_vec(
|
||||
&[true, true, true, true, true, true, true, true, true, true, true, true, true,
|
||||
true, true, true, true, true, true, true, true, true, true, true, true, true,
|
||||
@ -1999,15 +1999,15 @@ mod tests {
|
||||
assert!(!act.none() && act.all());
|
||||
// mixed
|
||||
|
||||
act = Bitv::from_elem(31u, false);
|
||||
act.set(0u, true);
|
||||
act.set(1u, true);
|
||||
act.set(2u, true);
|
||||
act.set(3u, true);
|
||||
act.set(4u, true);
|
||||
act.set(5u, true);
|
||||
act.set(6u, true);
|
||||
act.set(7u, true);
|
||||
act = Bitv::from_elem(31, false);
|
||||
act.set(0, true);
|
||||
act.set(1, true);
|
||||
act.set(2, true);
|
||||
act.set(3, true);
|
||||
act.set(4, true);
|
||||
act.set(5, true);
|
||||
act.set(6, true);
|
||||
act.set(7, true);
|
||||
assert!(act.eq_vec(
|
||||
&[true, true, true, true, true, true, true, true, false, false, false, false, false,
|
||||
false, false, false, false, false, false, false, false, false, false, false,
|
||||
@ -2015,15 +2015,15 @@ mod tests {
|
||||
assert!(!act.none() && !act.all());
|
||||
// mixed
|
||||
|
||||
act = Bitv::from_elem(31u, false);
|
||||
act.set(16u, true);
|
||||
act.set(17u, true);
|
||||
act.set(18u, true);
|
||||
act.set(19u, true);
|
||||
act.set(20u, true);
|
||||
act.set(21u, true);
|
||||
act.set(22u, true);
|
||||
act.set(23u, true);
|
||||
act = Bitv::from_elem(31, false);
|
||||
act.set(16, true);
|
||||
act.set(17, true);
|
||||
act.set(18, true);
|
||||
act.set(19, true);
|
||||
act.set(20, true);
|
||||
act.set(21, true);
|
||||
act.set(22, true);
|
||||
act.set(23, true);
|
||||
assert!(act.eq_vec(
|
||||
&[false, false, false, false, false, false, false, false, false, false, false,
|
||||
false, false, false, false, false, true, true, true, true, true, true, true, true,
|
||||
@ -2031,14 +2031,14 @@ mod tests {
|
||||
assert!(!act.none() && !act.all());
|
||||
// mixed
|
||||
|
||||
act = Bitv::from_elem(31u, false);
|
||||
act.set(24u, true);
|
||||
act.set(25u, true);
|
||||
act.set(26u, true);
|
||||
act.set(27u, true);
|
||||
act.set(28u, true);
|
||||
act.set(29u, true);
|
||||
act.set(30u, true);
|
||||
act = Bitv::from_elem(31, false);
|
||||
act.set(24, true);
|
||||
act.set(25, true);
|
||||
act.set(26, true);
|
||||
act.set(27, true);
|
||||
act.set(28, true);
|
||||
act.set(29, true);
|
||||
act.set(30, true);
|
||||
assert!(act.eq_vec(
|
||||
&[false, false, false, false, false, false, false, false, false, false, false,
|
||||
false, false, false, false, false, false, false, false, false, false, false,
|
||||
@ -2046,10 +2046,10 @@ mod tests {
|
||||
assert!(!act.none() && !act.all());
|
||||
// mixed
|
||||
|
||||
act = Bitv::from_elem(31u, false);
|
||||
act.set(3u, true);
|
||||
act.set(17u, true);
|
||||
act.set(30u, true);
|
||||
act = Bitv::from_elem(31, false);
|
||||
act.set(3, true);
|
||||
act.set(17, true);
|
||||
act.set(30, true);
|
||||
assert!(act.eq_vec(
|
||||
&[false, false, false, true, false, false, false, false, false, false, false, false,
|
||||
false, false, false, false, false, true, false, false, false, false, false, false,
|
||||
@ -2062,7 +2062,7 @@ mod tests {
|
||||
let mut act;
|
||||
// all 0
|
||||
|
||||
act = Bitv::from_elem(32u, false);
|
||||
act = Bitv::from_elem(32, false);
|
||||
assert!(act.eq_vec(
|
||||
&[false, false, false, false, false, false, false, false, false, false, false,
|
||||
false, false, false, false, false, false, false, false, false, false, false,
|
||||
@ -2070,7 +2070,7 @@ mod tests {
|
||||
assert!(act.none() && !act.all());
|
||||
// all 1
|
||||
|
||||
act = Bitv::from_elem(32u, true);
|
||||
act = Bitv::from_elem(32, true);
|
||||
assert!(act.eq_vec(
|
||||
&[true, true, true, true, true, true, true, true, true, true, true, true, true,
|
||||
true, true, true, true, true, true, true, true, true, true, true, true, true,
|
||||
@ -2078,15 +2078,15 @@ mod tests {
|
||||
assert!(!act.none() && act.all());
|
||||
// mixed
|
||||
|
||||
act = Bitv::from_elem(32u, false);
|
||||
act.set(0u, true);
|
||||
act.set(1u, true);
|
||||
act.set(2u, true);
|
||||
act.set(3u, true);
|
||||
act.set(4u, true);
|
||||
act.set(5u, true);
|
||||
act.set(6u, true);
|
||||
act.set(7u, true);
|
||||
act = Bitv::from_elem(32, false);
|
||||
act.set(0, true);
|
||||
act.set(1, true);
|
||||
act.set(2, true);
|
||||
act.set(3, true);
|
||||
act.set(4, true);
|
||||
act.set(5, true);
|
||||
act.set(6, true);
|
||||
act.set(7, true);
|
||||
assert!(act.eq_vec(
|
||||
&[true, true, true, true, true, true, true, true, false, false, false, false, false,
|
||||
false, false, false, false, false, false, false, false, false, false, false,
|
||||
@ -2094,15 +2094,15 @@ mod tests {
|
||||
assert!(!act.none() && !act.all());
|
||||
// mixed
|
||||
|
||||
act = Bitv::from_elem(32u, false);
|
||||
act.set(16u, true);
|
||||
act.set(17u, true);
|
||||
act.set(18u, true);
|
||||
act.set(19u, true);
|
||||
act.set(20u, true);
|
||||
act.set(21u, true);
|
||||
act.set(22u, true);
|
||||
act.set(23u, true);
|
||||
act = Bitv::from_elem(32, false);
|
||||
act.set(16, true);
|
||||
act.set(17, true);
|
||||
act.set(18, true);
|
||||
act.set(19, true);
|
||||
act.set(20, true);
|
||||
act.set(21, true);
|
||||
act.set(22, true);
|
||||
act.set(23, true);
|
||||
assert!(act.eq_vec(
|
||||
&[false, false, false, false, false, false, false, false, false, false, false,
|
||||
false, false, false, false, false, true, true, true, true, true, true, true, true,
|
||||
@ -2110,15 +2110,15 @@ mod tests {
|
||||
assert!(!act.none() && !act.all());
|
||||
// mixed
|
||||
|
||||
act = Bitv::from_elem(32u, false);
|
||||
act.set(24u, true);
|
||||
act.set(25u, true);
|
||||
act.set(26u, true);
|
||||
act.set(27u, true);
|
||||
act.set(28u, true);
|
||||
act.set(29u, true);
|
||||
act.set(30u, true);
|
||||
act.set(31u, true);
|
||||
act = Bitv::from_elem(32, false);
|
||||
act.set(24, true);
|
||||
act.set(25, true);
|
||||
act.set(26, true);
|
||||
act.set(27, true);
|
||||
act.set(28, true);
|
||||
act.set(29, true);
|
||||
act.set(30, true);
|
||||
act.set(31, true);
|
||||
assert!(act.eq_vec(
|
||||
&[false, false, false, false, false, false, false, false, false, false, false,
|
||||
false, false, false, false, false, false, false, false, false, false, false,
|
||||
@ -2126,11 +2126,11 @@ mod tests {
|
||||
assert!(!act.none() && !act.all());
|
||||
// mixed
|
||||
|
||||
act = Bitv::from_elem(32u, false);
|
||||
act.set(3u, true);
|
||||
act.set(17u, true);
|
||||
act.set(30u, true);
|
||||
act.set(31u, true);
|
||||
act = Bitv::from_elem(32, false);
|
||||
act.set(3, true);
|
||||
act.set(17, true);
|
||||
act.set(30, true);
|
||||
act.set(31, true);
|
||||
assert!(act.eq_vec(
|
||||
&[false, false, false, true, false, false, false, false, false, false, false, false,
|
||||
false, false, false, false, false, true, false, false, false, false, false, false,
|
||||
@ -2143,7 +2143,7 @@ mod tests {
|
||||
let mut act;
|
||||
// all 0
|
||||
|
||||
act = Bitv::from_elem(33u, false);
|
||||
act = Bitv::from_elem(33, false);
|
||||
assert!(act.eq_vec(
|
||||
&[false, false, false, false, false, false, false, false, false, false, false,
|
||||
false, false, false, false, false, false, false, false, false, false, false,
|
||||
@ -2151,7 +2151,7 @@ mod tests {
|
||||
assert!(act.none() && !act.all());
|
||||
// all 1
|
||||
|
||||
act = Bitv::from_elem(33u, true);
|
||||
act = Bitv::from_elem(33, true);
|
||||
assert!(act.eq_vec(
|
||||
&[true, true, true, true, true, true, true, true, true, true, true, true, true,
|
||||
true, true, true, true, true, true, true, true, true, true, true, true, true,
|
||||
@ -2159,15 +2159,15 @@ mod tests {
|
||||
assert!(!act.none() && act.all());
|
||||
// mixed
|
||||
|
||||
act = Bitv::from_elem(33u, false);
|
||||
act.set(0u, true);
|
||||
act.set(1u, true);
|
||||
act.set(2u, true);
|
||||
act.set(3u, true);
|
||||
act.set(4u, true);
|
||||
act.set(5u, true);
|
||||
act.set(6u, true);
|
||||
act.set(7u, true);
|
||||
act = Bitv::from_elem(33, false);
|
||||
act.set(0, true);
|
||||
act.set(1, true);
|
||||
act.set(2, true);
|
||||
act.set(3, true);
|
||||
act.set(4, true);
|
||||
act.set(5, true);
|
||||
act.set(6, true);
|
||||
act.set(7, true);
|
||||
assert!(act.eq_vec(
|
||||
&[true, true, true, true, true, true, true, true, false, false, false, false, false,
|
||||
false, false, false, false, false, false, false, false, false, false, false,
|
||||
@ -2175,15 +2175,15 @@ mod tests {
|
||||
assert!(!act.none() && !act.all());
|
||||
// mixed
|
||||
|
||||
act = Bitv::from_elem(33u, false);
|
||||
act.set(16u, true);
|
||||
act.set(17u, true);
|
||||
act.set(18u, true);
|
||||
act.set(19u, true);
|
||||
act.set(20u, true);
|
||||
act.set(21u, true);
|
||||
act.set(22u, true);
|
||||
act.set(23u, true);
|
||||
act = Bitv::from_elem(33, false);
|
||||
act.set(16, true);
|
||||
act.set(17, true);
|
||||
act.set(18, true);
|
||||
act.set(19, true);
|
||||
act.set(20, true);
|
||||
act.set(21, true);
|
||||
act.set(22, true);
|
||||
act.set(23, true);
|
||||
assert!(act.eq_vec(
|
||||
&[false, false, false, false, false, false, false, false, false, false, false,
|
||||
false, false, false, false, false, true, true, true, true, true, true, true, true,
|
||||
@ -2191,15 +2191,15 @@ mod tests {
|
||||
assert!(!act.none() && !act.all());
|
||||
// mixed
|
||||
|
||||
act = Bitv::from_elem(33u, false);
|
||||
act.set(24u, true);
|
||||
act.set(25u, true);
|
||||
act.set(26u, true);
|
||||
act.set(27u, true);
|
||||
act.set(28u, true);
|
||||
act.set(29u, true);
|
||||
act.set(30u, true);
|
||||
act.set(31u, true);
|
||||
act = Bitv::from_elem(33, false);
|
||||
act.set(24, true);
|
||||
act.set(25, true);
|
||||
act.set(26, true);
|
||||
act.set(27, true);
|
||||
act.set(28, true);
|
||||
act.set(29, true);
|
||||
act.set(30, true);
|
||||
act.set(31, true);
|
||||
assert!(act.eq_vec(
|
||||
&[false, false, false, false, false, false, false, false, false, false, false,
|
||||
false, false, false, false, false, false, false, false, false, false, false,
|
||||
@ -2207,12 +2207,12 @@ mod tests {
|
||||
assert!(!act.none() && !act.all());
|
||||
// mixed
|
||||
|
||||
act = Bitv::from_elem(33u, false);
|
||||
act.set(3u, true);
|
||||
act.set(17u, true);
|
||||
act.set(30u, true);
|
||||
act.set(31u, true);
|
||||
act.set(32u, true);
|
||||
act = Bitv::from_elem(33, false);
|
||||
act.set(3, true);
|
||||
act.set(17, true);
|
||||
act.set(30, true);
|
||||
act.set(31, true);
|
||||
act.set(32, true);
|
||||
assert!(act.eq_vec(
|
||||
&[false, false, false, true, false, false, false, false, false, false, false, false,
|
||||
false, false, false, false, false, true, false, false, false, false, false, false,
|
||||
@ -2222,15 +2222,15 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_equal_differing_sizes() {
|
||||
let v0 = Bitv::from_elem(10u, false);
|
||||
let v1 = Bitv::from_elem(11u, false);
|
||||
let v0 = Bitv::from_elem(10, false);
|
||||
let v1 = Bitv::from_elem(11, false);
|
||||
assert!(v0 != v1);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_equal_greatly_differing_sizes() {
|
||||
let v0 = Bitv::from_elem(10u, false);
|
||||
let v1 = Bitv::from_elem(110u, false);
|
||||
let v0 = Bitv::from_elem(10, false);
|
||||
let v1 = Bitv::from_elem(110, false);
|
||||
assert!(v0 != v1);
|
||||
}
|
||||
|
||||
@ -2248,12 +2248,12 @@ mod tests {
|
||||
#[test]
|
||||
fn test_equal_sneaky_big() {
|
||||
let mut a = Bitv::from_elem(100, false);
|
||||
for i in 0u..100 {
|
||||
for i in 0..100 {
|
||||
a.set(i, true);
|
||||
}
|
||||
|
||||
let mut b = Bitv::from_elem(100, true);
|
||||
for i in 0u..100 {
|
||||
for i in 0..100 {
|
||||
b.set(i, true);
|
||||
}
|
||||
|
||||
@ -2350,8 +2350,8 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_bitv_lt() {
|
||||
let mut a = Bitv::from_elem(5u, false);
|
||||
let mut b = Bitv::from_elem(5u, false);
|
||||
let mut a = Bitv::from_elem(5, false);
|
||||
let mut b = Bitv::from_elem(5, false);
|
||||
|
||||
assert!(!(a < b) && !(b < a));
|
||||
b.set(2, true);
|
||||
@ -2366,8 +2366,8 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_ord() {
|
||||
let mut a = Bitv::from_elem(5u, false);
|
||||
let mut b = Bitv::from_elem(5u, false);
|
||||
let mut a = Bitv::from_elem(5, false);
|
||||
let mut b = Bitv::from_elem(5, false);
|
||||
|
||||
assert!(a <= b && a >= b);
|
||||
a.set(1, true);
|
||||
@ -2542,7 +2542,7 @@ mod bitv_bench {
|
||||
let mut r = rng();
|
||||
let mut bitv = 0 as usize;
|
||||
b.iter(|| {
|
||||
for _ in 0u..100 {
|
||||
for _ in 0..100 {
|
||||
bitv |= 1 << ((r.next_u32() as usize) % u32::BITS);
|
||||
}
|
||||
black_box(&bitv);
|
||||
@ -2554,7 +2554,7 @@ mod bitv_bench {
|
||||
let mut r = rng();
|
||||
let mut bitv = Bitv::from_elem(BENCH_BITS, false);
|
||||
b.iter(|| {
|
||||
for _ in 0u..100 {
|
||||
for _ in 0..100 {
|
||||
bitv.set((r.next_u32() as usize) % BENCH_BITS, true);
|
||||
}
|
||||
black_box(&bitv);
|
||||
@ -2566,7 +2566,7 @@ mod bitv_bench {
|
||||
let mut r = rng();
|
||||
let mut bitv = Bitv::from_elem(BENCH_BITS, false);
|
||||
b.iter(|| {
|
||||
for _ in 0u..100 {
|
||||
for _ in 0..100 {
|
||||
bitv.set((r.next_u32() as usize) % BENCH_BITS, r.gen());
|
||||
}
|
||||
black_box(&bitv);
|
||||
@ -2578,7 +2578,7 @@ mod bitv_bench {
|
||||
let mut r = rng();
|
||||
let mut bitv = Bitv::from_elem(u32::BITS, false);
|
||||
b.iter(|| {
|
||||
for _ in 0u..100 {
|
||||
for _ in 0..100 {
|
||||
bitv.set((r.next_u32() as usize) % u32::BITS, true);
|
||||
}
|
||||
black_box(&bitv);
|
||||
@ -2598,8 +2598,8 @@ mod bitv_bench {
|
||||
fn bench_bitv_small_iter(b: &mut Bencher) {
|
||||
let bitv = Bitv::from_elem(u32::BITS, false);
|
||||
b.iter(|| {
|
||||
let mut sum = 0u;
|
||||
for _ in 0u..10 {
|
||||
let mut sum = 0;
|
||||
for _ in 0..10 {
|
||||
for pres in &bitv {
|
||||
sum += pres as usize;
|
||||
}
|
||||
@ -2612,7 +2612,7 @@ mod bitv_bench {
|
||||
fn bench_bitv_big_iter(b: &mut Bencher) {
|
||||
let bitv = Bitv::from_elem(BENCH_BITS, false);
|
||||
b.iter(|| {
|
||||
let mut sum = 0u;
|
||||
let mut sum = 0;
|
||||
for pres in &bitv {
|
||||
sum += pres as usize;
|
||||
}
|
||||
@ -2663,7 +2663,7 @@ mod bitv_set_test {
|
||||
let idxs: Vec<_> = bitv.iter().collect();
|
||||
assert_eq!(idxs, vec![0, 2, 3]);
|
||||
|
||||
let long: BitvSet = (0u..10000).filter(|&n| n % 2 == 0).collect();
|
||||
let long: BitvSet = (0..10000).filter(|&n| n % 2 == 0).collect();
|
||||
let real: Vec<_> = range_step(0, 10000, 2).collect();
|
||||
|
||||
let idxs: Vec<_> = long.iter().collect();
|
||||
@ -2677,8 +2677,8 @@ mod bitv_set_test {
|
||||
for &b in &bools {
|
||||
for &l in &lengths {
|
||||
let bitset = BitvSet::from_bitv(Bitv::from_elem(l, b));
|
||||
assert_eq!(bitset.contains(&1u), b);
|
||||
assert_eq!(bitset.contains(&(l-1u)), b);
|
||||
assert_eq!(bitset.contains(&1), b);
|
||||
assert_eq!(bitset.contains(&(l-1)), b);
|
||||
assert!(!bitset.contains(&l));
|
||||
}
|
||||
}
|
||||
|
@ -26,7 +26,6 @@
|
||||
#![feature(box_syntax)]
|
||||
#![feature(core)]
|
||||
#![feature(hash)]
|
||||
#![feature(int_uint)]
|
||||
#![feature(staged_api)]
|
||||
#![feature(unboxed_closures)]
|
||||
#![feature(unicode)]
|
||||
|
@ -32,8 +32,8 @@ use std::cmp;
|
||||
|
||||
use alloc::heap;
|
||||
|
||||
static INITIAL_CAPACITY: usize = 7u; // 2^3 - 1
|
||||
static MINIMUM_CAPACITY: usize = 1u; // 2 - 1
|
||||
static INITIAL_CAPACITY: usize = 7; // 2^3 - 1
|
||||
static MINIMUM_CAPACITY: usize = 1; // 2 - 1
|
||||
|
||||
/// `RingBuf` is a circular buffer, which can be used as a double-ended queue efficiently.
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
|
@ -1116,7 +1116,7 @@ pub trait SliceConcatExt<T: ?Sized, U> {
|
||||
|
||||
impl<T: Clone, V: AsSlice<T>> SliceConcatExt<T, Vec<T>> for [V] {
|
||||
fn concat(&self) -> Vec<T> {
|
||||
let size = self.iter().fold(0u, |acc, v| acc + v.as_slice().len());
|
||||
let size = self.iter().fold(0, |acc, v| acc + v.as_slice().len());
|
||||
let mut result = Vec::with_capacity(size);
|
||||
for v in self {
|
||||
result.push_all(v.as_slice())
|
||||
@ -1125,7 +1125,7 @@ impl<T: Clone, V: AsSlice<T>> SliceConcatExt<T, Vec<T>> for [V] {
|
||||
}
|
||||
|
||||
fn connect(&self, sep: &T) -> Vec<T> {
|
||||
let size = self.iter().fold(0u, |acc, v| acc + v.as_slice().len());
|
||||
let size = self.iter().fold(0, |acc, v| acc + v.as_slice().len());
|
||||
let mut result = Vec::with_capacity(size + self.len());
|
||||
let mut first = true;
|
||||
for v in self {
|
||||
@ -1301,7 +1301,7 @@ impl<T: Clone> Iterator for Permutations<T> {
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
fn insertion_sort<T, F>(v: &mut [T], mut compare: F) where F: FnMut(&T, &T) -> Ordering {
|
||||
let len = v.len() as int;
|
||||
let len = v.len() as isize;
|
||||
let buf_v = v.as_mut_ptr();
|
||||
|
||||
// 1 <= i < len;
|
||||
@ -1371,7 +1371,7 @@ fn merge_sort<T, F>(v: &mut [T], mut compare: F) where F: FnMut(&T, &T) -> Order
|
||||
let mut working_space = Vec::with_capacity(2 * len);
|
||||
// these both are buffers of length `len`.
|
||||
let mut buf_dat = working_space.as_mut_ptr();
|
||||
let mut buf_tmp = unsafe {buf_dat.offset(len as int)};
|
||||
let mut buf_tmp = unsafe {buf_dat.offset(len as isize)};
|
||||
|
||||
// length `len`.
|
||||
let buf_v = v.as_ptr();
|
||||
@ -1387,17 +1387,17 @@ fn merge_sort<T, F>(v: &mut [T], mut compare: F) where F: FnMut(&T, &T) -> Order
|
||||
// start <= i < len;
|
||||
for i in start..cmp::min(start + insertion, len) {
|
||||
// j satisfies: start <= j <= i;
|
||||
let mut j = i as int;
|
||||
let mut j = i as isize;
|
||||
unsafe {
|
||||
// `i` is in bounds.
|
||||
let read_ptr = buf_v.offset(i as int);
|
||||
let read_ptr = buf_v.offset(i as isize);
|
||||
|
||||
// find where to insert, we need to do strict <,
|
||||
// rather than <=, to maintain stability.
|
||||
|
||||
// start <= j - 1 < len, so .offset(j - 1) is in
|
||||
// bounds.
|
||||
while j > start as int &&
|
||||
while j > start as isize &&
|
||||
compare(&*read_ptr, &*buf_dat.offset(j - 1)) == Less {
|
||||
j -= 1;
|
||||
}
|
||||
@ -1431,24 +1431,24 @@ fn merge_sort<T, F>(v: &mut [T], mut compare: F) where F: FnMut(&T, &T) -> Order
|
||||
// the end of the first run & start of the
|
||||
// second. Offset of `len` is defined, since this is
|
||||
// precisely one byte past the end of the object.
|
||||
let right_start = buf_dat.offset(cmp::min(start + width, len) as int);
|
||||
let right_start = buf_dat.offset(cmp::min(start + width, len) as isize);
|
||||
// end of the second. Similar reasoning to the above re safety.
|
||||
let right_end_idx = cmp::min(start + 2 * width, len);
|
||||
let right_end = buf_dat.offset(right_end_idx as int);
|
||||
let right_end = buf_dat.offset(right_end_idx as isize);
|
||||
|
||||
// the pointers to the elements under consideration
|
||||
// from the two runs.
|
||||
|
||||
// both of these are in bounds.
|
||||
let mut left = buf_dat.offset(start as int);
|
||||
let mut left = buf_dat.offset(start as isize);
|
||||
let mut right = right_start;
|
||||
|
||||
// where we're putting the results, it is a run of
|
||||
// length `2*width`, so we step it once for each step
|
||||
// of either `left` or `right`. `buf_tmp` has length
|
||||
// `len`, so these are in bounds.
|
||||
let mut out = buf_tmp.offset(start as int);
|
||||
let out_end = buf_tmp.offset(right_end_idx as int);
|
||||
let mut out = buf_tmp.offset(start as isize);
|
||||
let out_end = buf_tmp.offset(right_end_idx as isize);
|
||||
|
||||
while out < out_end {
|
||||
// Either the left or the right run are exhausted,
|
||||
@ -2373,7 +2373,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_mut_rev_iterator() {
|
||||
let mut xs = [1u, 2, 3, 4, 5];
|
||||
let mut xs = [1, 2, 3, 4, 5];
|
||||
for (i,x) in xs.iter_mut().rev().enumerate() {
|
||||
*x += i;
|
||||
}
|
||||
@ -2382,13 +2382,13 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_move_iterator() {
|
||||
let xs = vec![1u,2,3,4,5];
|
||||
let xs = vec![1,2,3,4,5];
|
||||
assert_eq!(xs.into_iter().fold(0, |a: usize, b: usize| 10*a + b), 12345);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_move_rev_iterator() {
|
||||
let xs = vec![1u,2,3,4,5];
|
||||
let xs = vec![1,2,3,4,5];
|
||||
assert_eq!(xs.into_iter().rev().fold(0, |a: usize, b: usize| 10*a + b), 54321);
|
||||
}
|
||||
|
||||
@ -2592,7 +2592,7 @@ mod tests {
|
||||
test_show_vec!(empty, "[]");
|
||||
test_show_vec!(vec![1], "[1]");
|
||||
test_show_vec!(vec![1, 2, 3], "[1, 2, 3]");
|
||||
test_show_vec!(vec![vec![], vec![1u], vec![1u, 1u]],
|
||||
test_show_vec!(vec![vec![], vec![1], vec![1, 1]],
|
||||
"[[], [1], [1, 1]]");
|
||||
|
||||
let empty_mut: &mut [i32] = &mut[];
|
||||
@ -2601,7 +2601,7 @@ mod tests {
|
||||
test_show_vec!(v, "[1]");
|
||||
let v = &mut[1, 2, 3];
|
||||
test_show_vec!(v, "[1, 2, 3]");
|
||||
let v: &mut[&mut[_]] = &mut[&mut[], &mut[1u], &mut[1u, 1u]];
|
||||
let v: &mut[&mut[_]] = &mut[&mut[], &mut[1], &mut[1, 1]];
|
||||
test_show_vec!(v, "[[], [1], [1, 1]]");
|
||||
}
|
||||
|
||||
@ -2677,7 +2677,7 @@ mod tests {
|
||||
fn test_iter_zero_sized() {
|
||||
let mut v = vec![Foo, Foo, Foo];
|
||||
assert_eq!(v.len(), 3);
|
||||
let mut cnt = 0u;
|
||||
let mut cnt = 0;
|
||||
|
||||
for f in &v {
|
||||
assert!(*f == Foo);
|
||||
@ -3016,7 +3016,7 @@ mod bench {
|
||||
let mut rng = weak_rng();
|
||||
b.iter(|| {
|
||||
let mut v: Vec<_> = repeat((0, 0)).take(30).collect();
|
||||
for _ in 0u..100 {
|
||||
for _ in 0..100 {
|
||||
let l = v.len();
|
||||
v.insert(rng.gen::<usize>() % (l + 1),
|
||||
(1, 1));
|
||||
@ -3028,7 +3028,7 @@ mod bench {
|
||||
let mut rng = weak_rng();
|
||||
b.iter(|| {
|
||||
let mut v: Vec<_> = repeat((0, 0)).take(130).collect();
|
||||
for _ in 0u..100 {
|
||||
for _ in 0..100 {
|
||||
let l = v.len();
|
||||
v.remove(rng.gen::<usize>() % l);
|
||||
}
|
||||
|
@ -469,7 +469,7 @@ impl String {
|
||||
// Attempt to not use an intermediate buffer by just pushing bytes
|
||||
// directly onto this string.
|
||||
let slice = RawSlice {
|
||||
data: self.vec.as_ptr().offset(cur_len as int),
|
||||
data: self.vec.as_ptr().offset(cur_len as isize),
|
||||
len: 4,
|
||||
};
|
||||
let used = ch.encode_utf8(mem::transmute(slice)).unwrap_or(0);
|
||||
@ -569,8 +569,8 @@ impl String {
|
||||
|
||||
let CharRange { ch, next } = self.char_range_at(idx);
|
||||
unsafe {
|
||||
ptr::copy_memory(self.vec.as_mut_ptr().offset(idx as int),
|
||||
self.vec.as_ptr().offset(next as int),
|
||||
ptr::copy_memory(self.vec.as_mut_ptr().offset(idx as isize),
|
||||
self.vec.as_ptr().offset(next as isize),
|
||||
len - next);
|
||||
self.vec.set_len(len - (next - idx));
|
||||
}
|
||||
@ -599,10 +599,10 @@ impl String {
|
||||
let amt = ch.encode_utf8(&mut bits).unwrap();
|
||||
|
||||
unsafe {
|
||||
ptr::copy_memory(self.vec.as_mut_ptr().offset((idx + amt) as int),
|
||||
self.vec.as_ptr().offset(idx as int),
|
||||
ptr::copy_memory(self.vec.as_mut_ptr().offset((idx + amt) as isize),
|
||||
self.vec.as_ptr().offset(idx as isize),
|
||||
len - idx);
|
||||
ptr::copy_memory(self.vec.as_mut_ptr().offset(idx as int),
|
||||
ptr::copy_memory(self.vec.as_mut_ptr().offset(idx as isize),
|
||||
bits.as_ptr(),
|
||||
amt);
|
||||
self.vec.set_len(len + amt);
|
||||
|
@ -234,7 +234,7 @@ impl<T> Vec<T> {
|
||||
/// mem::forget(v);
|
||||
///
|
||||
/// // Overwrite memory with 4, 5, 6
|
||||
/// for i in 0..len as int {
|
||||
/// for i in 0..len as isize {
|
||||
/// ptr::write(p.offset(i), 4 + i);
|
||||
/// }
|
||||
///
|
||||
@ -457,7 +457,7 @@ impl<T> Vec<T> {
|
||||
let end = if mem::size_of::<T>() == 0 {
|
||||
(ptr as usize + self.len()) as *const T
|
||||
} else {
|
||||
ptr.offset(self.len() as int) as *const T
|
||||
ptr.offset(self.len() as isize) as *const T
|
||||
};
|
||||
mem::forget(self);
|
||||
IntoIter { allocation: ptr, cap: cap, ptr: begin, end: end }
|
||||
@ -473,7 +473,7 @@ impl<T> Vec<T> {
|
||||
/// # Examples
|
||||
///
|
||||
/// ```
|
||||
/// let mut v = vec![1u, 2, 3, 4];
|
||||
/// let mut v = vec![1, 2, 3, 4];
|
||||
/// unsafe {
|
||||
/// v.set_len(1);
|
||||
/// }
|
||||
@ -539,7 +539,7 @@ impl<T> Vec<T> {
|
||||
unsafe { // infallible
|
||||
// The spot to put the new value
|
||||
{
|
||||
let p = self.as_mut_ptr().offset(index as int);
|
||||
let p = self.as_mut_ptr().offset(index as isize);
|
||||
// Shift everything over to make space. (Duplicating the
|
||||
// `index`th element into two consecutive places.)
|
||||
ptr::copy_memory(p.offset(1), &*p, len - index);
|
||||
@ -573,7 +573,7 @@ impl<T> Vec<T> {
|
||||
let ret;
|
||||
{
|
||||
// the place we are taking from.
|
||||
let ptr = self.as_mut_ptr().offset(index as int);
|
||||
let ptr = self.as_mut_ptr().offset(index as isize);
|
||||
// copy it out, unsafely having a copy of the value on
|
||||
// the stack and in the vector at the same time.
|
||||
ret = ptr::read(ptr);
|
||||
@ -655,7 +655,7 @@ impl<T> Vec<T> {
|
||||
}
|
||||
|
||||
unsafe {
|
||||
let end = (*self.ptr).offset(self.len as int);
|
||||
let end = (*self.ptr).offset(self.len as isize);
|
||||
ptr::write(&mut *end, value);
|
||||
self.len += 1;
|
||||
}
|
||||
@ -743,7 +743,7 @@ impl<T> Vec<T> {
|
||||
let end = if mem::size_of::<T>() == 0 {
|
||||
(*self.ptr as usize + self.len()) as *const T
|
||||
} else {
|
||||
(*self.ptr).offset(self.len() as int) as *const T
|
||||
(*self.ptr).offset(self.len() as isize) as *const T
|
||||
};
|
||||
self.set_len(0);
|
||||
Drain {
|
||||
@ -835,7 +835,7 @@ impl<T> Vec<T> {
|
||||
// types are passed to the allocator by `Vec`.
|
||||
assert!(mem::min_align_of::<T>() == mem::min_align_of::<U>());
|
||||
|
||||
// This `as int` cast is safe, because the size of the elements of the
|
||||
// This `as isize` cast is safe, because the size of the elements of the
|
||||
// vector is not 0, and:
|
||||
//
|
||||
// 1) If the size of the elements in the vector is 1, the `int` may
|
||||
@ -852,7 +852,7 @@ impl<T> Vec<T> {
|
||||
//
|
||||
// 2) If the size of the elements in the vector is >1, the `usize` ->
|
||||
// `int` conversion can't overflow.
|
||||
let offset = vec.len() as int;
|
||||
let offset = vec.len() as isize;
|
||||
let start = vec.as_mut_ptr();
|
||||
|
||||
let mut pv = PartialVecNonZeroSized {
|
||||
@ -1179,8 +1179,8 @@ impl<T: PartialEq> Vec<T> {
|
||||
let mut w = 1;
|
||||
|
||||
while r < ln {
|
||||
let p_r = p.offset(r as int);
|
||||
let p_wm1 = p.offset((w - 1) as int);
|
||||
let p_r = p.offset(r as isize);
|
||||
let p_wm1 = p.offset((w - 1) as isize);
|
||||
if *p_r != *p_wm1 {
|
||||
if r != w {
|
||||
let p_w = p_wm1.offset(1);
|
||||
@ -1648,7 +1648,7 @@ impl<T> Iterator for IntoIter<T> {
|
||||
self.ptr = mem::transmute(self.ptr as usize + 1);
|
||||
|
||||
// Use a non-null pointer value
|
||||
Some(ptr::read(mem::transmute(1u)))
|
||||
Some(ptr::read(EMPTY as *mut T))
|
||||
} else {
|
||||
let old = self.ptr;
|
||||
self.ptr = self.ptr.offset(1);
|
||||
@ -1681,7 +1681,7 @@ impl<T> DoubleEndedIterator for IntoIter<T> {
|
||||
self.end = mem::transmute(self.end as usize - 1);
|
||||
|
||||
// Use a non-null pointer value
|
||||
Some(ptr::read(mem::transmute(1u)))
|
||||
Some(ptr::read(EMPTY as *mut T))
|
||||
} else {
|
||||
self.end = self.end.offset(-1);
|
||||
|
||||
@ -1736,7 +1736,7 @@ impl<'a, T> Iterator for Drain<'a, T> {
|
||||
self.ptr = mem::transmute(self.ptr as usize + 1);
|
||||
|
||||
// Use a non-null pointer value
|
||||
Some(ptr::read(mem::transmute(1u)))
|
||||
Some(ptr::read(EMPTY as *mut T))
|
||||
} else {
|
||||
let old = self.ptr;
|
||||
self.ptr = self.ptr.offset(1);
|
||||
@ -1769,7 +1769,7 @@ impl<'a, T> DoubleEndedIterator for Drain<'a, T> {
|
||||
self.end = mem::transmute(self.end as usize - 1);
|
||||
|
||||
// Use a non-null pointer value
|
||||
Some(ptr::read(mem::transmute(1u)))
|
||||
Some(ptr::read(EMPTY as *mut T))
|
||||
} else {
|
||||
self.end = self.end.offset(-1);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user