This commit is contained in:
Jihyun Yu 2013-05-28 12:35:06 +09:00
parent e6a838d051
commit 4521c34775

View File

@ -246,7 +246,14 @@ fn difference(&self, other: &SmallIntSet, f: &fn(&uint) -> bool) -> bool {
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 @@ fn intersection(&self, other: &SmallIntSet, f: &fn(&uint) -> bool) -> bool {
/// 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;
}
}