diff options
| author | Jihyun Yu <yjh0502@gmail.com> | 2013-05-28 12:35:06 +0900 |
|---|---|---|
| committer | Jihyun Yu <yjh0502@gmail.com> | 2013-05-28 12:35:06 +0900 |
| commit | 4521c347757329d4166e1a1c0239de2fcdd508e9 (patch) | |
| tree | d8d4ad8faada628e8d421e2c2e8c8e23b8a2d9f5 | |
| parent | e6a838d05100baec0df9ae8b16b2127470a593b8 (diff) | |
| download | rust-4521c347757329d4166e1a1c0239de2fcdd508e9.tar.gz rust-4521c347757329d4166e1a1c0239de2fcdd508e9.zip | |
Fix #6696
| -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; } } |
