Skip to content

Commit ec23b11

Browse files
thestingergraydon
authored andcommitted
---
yaml --- r: 42471 b: refs/heads/try c: 4f92d8f h: refs/heads/master i: 42469: ed86e81 42467: 0589763 42463: dca9d33 v: v3
1 parent 9594507 commit ec23b11

File tree

2 files changed

+19
-5
lines changed

2 files changed

+19
-5
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: 9fb49088b35ae82c290ed112cdc87b71986d3d7e
5+
refs/heads/try: 4f92d8fb52ba335abae39bdd38e72ff42cd37bb2
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 & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -338,10 +338,24 @@ impl <T: Ord> TreeSet<T> {
338338

339339
/// Visit the values (in-order) representing the intersection
340340
pure fn intersection(&self, other: &TreeSet<T>, f: fn(&T) -> bool) {
341-
// FIXME: this is a naive O(n*log(m)) implementation, could be O(n + m)
342-
for self.each |x| {
343-
if other.contains(x) {
344-
if !f(x) { break }
341+
let mut x = self.iter();
342+
let mut y = other.iter();
343+
344+
unsafe { // purity workaround
345+
let mut a = x.next();
346+
let mut b = y.next();
347+
348+
while a.is_some() && b.is_some() {
349+
let a1 = a.unwrap();
350+
let b1 = b.unwrap();
351+
if a1 < b1 {
352+
a = x.next();
353+
} else {
354+
if !(b1 < a1) {
355+
if !f(a1) { return }
356+
}
357+
b = y.next();
358+
}
345359
}
346360
}
347361
}

0 commit comments

Comments
 (0)