diff options
| author | bors <bors@rust-lang.org> | 2013-05-28 15:40:53 -0700 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2013-05-28 15:40:53 -0700 |
| commit | 5676056ae6dd3a10d2c7323375ace3ca2fe1c308 (patch) | |
| tree | 9b7af6bf6e5c17da365bd4f97f54932c01a05ac4 | |
| parent | 9a06ff05908234d92de9673734e089b0c315bdfd (diff) | |
| parent | 4521c347757329d4166e1a1c0239de2fcdd508e9 (diff) | |
| download | rust-5676056ae6dd3a10d2c7323375ace3ca2fe1c308.tar.gz rust-5676056ae6dd3a10d2c7323375ace3ca2fe1c308.zip | |
auto merge of #6775 : yjh0502/rust/issue_6696, r=catamorphism
| -rw-r--r-- | src/libextra/smallintmap.rs | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/src/libextra/smallintmap.rs b/src/libextra/smallintmap.rs index 069368d3fea..a3c02b2366d 100644 --- a/src/libextra/smallintmap.rs +++ b/src/libextra/smallintmap.rs @@ -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; } } |
