diff --git a/src/libstd/treemap.rs b/src/libstd/treemap.rs index 44345bdd853..9ebb760358b 100644 --- a/src/libstd/treemap.rs +++ b/src/libstd/treemap.rs @@ -229,13 +229,13 @@ impl TreeSet { /// Return true if the set has no elements in common with `other`. /// This is equivalent to checking for an empty intersection. pure fn is_disjoint(&self, other: &TreeSet) -> bool { - // FIXME: this is a naive O(n*log(m)) implementation, could be O(n) + // FIXME: this is a naive O(n*log(m)) implementation, could be O(n + m) !iter::any(self, |x| other.contains(x)) } /// Check of the set is a subset of another pure fn is_subset(&self, other: &TreeSet) -> bool { - // FIXME: this is a naive O(n*log(m)) implementation, could be O(n) + // FIXME: this is a naive O(n*log(m)) implementation, could be O(n + m) !iter::any(self, |x| !other.contains(x)) } @@ -278,14 +278,21 @@ impl TreeSet { } /// Visit the values (in-order) representing the symmetric difference - pure fn symmetric_difference(&self, _other: &TreeSet, + pure fn symmetric_difference(&self, other: &TreeSet, _f: fn(&T) -> bool) { + unsafe { // purity workaround + let mut x = self.map.iter(); + let mut y = other.map.iter(); + + let mut a = x.next(); + let mut b = y.next(); + } fail ~"not yet implemented" } /// Visit the values (in-order) representing the intersection pure fn intersection(&self, other: &TreeSet, f: fn(&T) -> bool) { - // FIXME: this is a naive O(n*log(m)) implementation, could be O(n) + // FIXME: this is a naive O(n*log(m)) implementation, could be O(n + m) for self.each |x| { if other.contains(x) { if !f(x) { break } @@ -294,7 +301,14 @@ impl TreeSet { } /// Visit the values (in-order) representing the union - pure fn union(&self, _other: &TreeSet, _f: fn(&T) -> bool) { + pure fn union(&self, other: &TreeSet, _f: fn(&T) -> bool) { + unsafe { // purity workaround + let mut x = self.map.iter(); + let mut y = other.map.iter(); + + let mut a = x.next(); + let mut b = y.next(); + } fail ~"not yet implemented" } }