Skip to content

Commit 4521c34

Browse files
committed
Fix #6696
1 parent e6a838d commit 4521c34

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

src/libextra/smallintmap.rs

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,14 @@ impl Set<uint> for SmallIntSet {
246246
fn symmetric_difference(&self,
247247
other: &SmallIntSet,
248248
f: &fn(&uint) -> bool) -> bool {
249-
self.difference(other, f) && other.difference(self, f)
249+
let len = cmp::max(self.map.v.len() ,other.map.v.len());
250+
251+
for uint::range(0, len) |i| {
252+
if self.contains(&i) ^ other.contains(&i) {
253+
if !f(&i) { return false; }
254+
}
255+
}
256+
return true;
250257
}
251258

252259
/// Visit the values representing the uintersection
@@ -256,7 +263,14 @@ impl Set<uint> for SmallIntSet {
256263

257264
/// Visit the values representing the union
258265
fn union(&self, other: &SmallIntSet, f: &fn(&uint) -> bool) -> bool {
259-
self.each(f) && other.each(|v| self.contains(v) || f(v))
266+
let len = cmp::max(self.map.v.len() ,other.map.v.len());
267+
268+
for uint::range(0, len) |i| {
269+
if self.contains(&i) || other.contains(&i) {
270+
if !f(&i) { return false; }
271+
}
272+
}
273+
return true;
260274
}
261275
}
262276

0 commit comments

Comments
 (0)