Skip to content

Commit

Permalink
auto merge of #6775 : yjh0502/rust/issue_6696, r=catamorphism
Browse files Browse the repository at this point in the history
  • Loading branch information
bors committed May 28, 2013
2 parents 9a06ff0 + 4521c34 commit 5676056
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions src/libextra/smallintmap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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;
}
}

Expand Down

0 comments on commit 5676056

Please sign in to comment.