Skip to content

Commit b41d4a1

Browse files
thestingerbrson
authored andcommitted
---
yaml --- r: 35571 b: refs/heads/master c: 285496b h: refs/heads/master i: 35569: 790d1fc 35567: 5260849 v: v3
1 parent 0373bce commit b41d4a1

File tree

2 files changed

+12
-11
lines changed

2 files changed

+12
-11
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: 757a2afb6b80cb4dbdcb8069f1af511ec42e8670
2+
refs/heads/master: 285496bd550817094c31167e7e49378a35560842
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: eb8fd119c65c67f3b1b8268cc7341c22d39b7b61
55
refs/heads/try: d324a424d8f84b1eb049b12cf34182bda91b0024

trunk/src/libstd/priority_queue.rs

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,16 @@ impl <T: Copy Ord> PriorityQueue<T> {
9191
q.to_vec()
9292
}
9393

94+
static pub pure fn from_vec(xs: ~[T]) -> PriorityQueue<T> {
95+
let mut q = PriorityQueue{data: xs,};
96+
let mut n = q.len() / 2;
97+
while n > 0 {
98+
n -= 1;
99+
unsafe { q.siftup(n) }; // purity-checking workaround
100+
}
101+
q
102+
}
103+
94104
priv fn siftdown(&mut self, startpos: uint, pos: uint) {
95105
let mut pos = pos;
96106
let newitem = self.data[pos];
@@ -133,20 +143,11 @@ impl <T: Copy Ord> PriorityQueue<T> {
133143
}
134144
}
135145

136-
pub pure fn from_vec<T: Copy Ord>(xs: ~[T]) -> PriorityQueue<T> {
137-
let mut q = PriorityQueue{data: xs,};
138-
let mut n = q.len() / 2;
139-
while n > 0 {
140-
n -= 1;
141-
unsafe { q.siftup(n) }; // purity-checking workaround
142-
}
143-
q
144-
}
145-
146146
#[cfg(test)]
147147
mod tests {
148148
use sort::merge_sort;
149149
use core::cmp::le;
150+
use PriorityQueue::from_vec;
150151

151152
#[test]
152153
fn test_top_and_pop() {

0 commit comments

Comments
 (0)