auto merge of #6775 : yjh0502/rust/issue_6696, r=catamorphism

This commit is contained in:
bors 2013-05-28 15:40:53 -07:00
commit 5676056ae6

View File

@ -246,7 +246,14 @@ impl Set<uint> for SmallIntSet {
fn symmetric_difference(&self,
other: &SmallIntSet,
f: &fn(&uint) -> bool) -> bool {
self.difference(other, f) && other.difference(self, f)
let len = cmp::max(self.map.v.len() ,other.map.v.len());
for uint::range(0, len) |i| {
if self.contains(&i) ^ other.contains(&i) {
if !f(&i) { return false; }
}
}
return true;
}
/// Visit the values representing the uintersection
@ -256,7 +263,14 @@ impl Set<uint> for SmallIntSet {
/// Visit the values representing the union
fn union(&self, other: &SmallIntSet, f: &fn(&uint) -> bool) -> bool {
self.each(f) && other.each(|v| self.contains(v) || f(v))
let len = cmp::max(self.map.v.len() ,other.map.v.len());
for uint::range(0, len) |i| {
if self.contains(&i) || other.contains(&i) {
if !f(&i) { return false; }
}
}
return true;
}
}