Skip to content

Commit 9594507

Browse files
thestingergraydon
authored andcommitted
---
yaml --- r: 42470 b: refs/heads/try c: 9fb4908 h: refs/heads/master v: v3
1 parent ed86e81 commit 9594507

File tree

2 files changed

+19
-3
lines changed

2 files changed

+19
-3
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
refs/heads/master: 19dfec2aaf746535de1521f68421f9980dbf25de
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 2f46b763da2c098913884f101b6d71d69af41b49
5-
refs/heads/try: 8935771377207f74c69d6011cde006998c3a8fb8
5+
refs/heads/try: 9fb49088b35ae82c290ed112cdc87b71986d3d7e
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: a810c03263670238bccd64cabb12a23a46e3a278

branches/try/src/libstd/treemap.rs

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -237,8 +237,24 @@ impl <T: Ord> TreeSet<T> {
237237
/// Return true if the set has no elements in common with `other`.
238238
/// This is equivalent to checking for an empty intersection.
239239
pure fn is_disjoint(&self, other: &TreeSet<T>) -> bool {
240-
// FIXME: this is a naive O(n*log(m)) implementation, could be O(n + m)
241-
!iter::any(self, |x| other.contains(x))
240+
let mut x = self.iter();
241+
let mut y = other.iter();
242+
unsafe { // purity workaround
243+
let mut a = x.next();
244+
let mut b = y.next();
245+
while a.is_some() && b.is_some() {
246+
let a1 = a.unwrap();
247+
let b1 = b.unwrap();
248+
if a1 < b1 {
249+
a = x.next();
250+
} else if b1 < a1 {
251+
b = y.next();
252+
} else {
253+
return false;
254+
}
255+
}
256+
}
257+
true
242258
}
243259

244260
/// Check of the set is a subset of another

0 commit comments

Comments
 (0)