Skip to content

Commit 7024808

Browse files
thestingerbrson
authored andcommitted
---
yaml --- r: 36764 b: refs/heads/try2 c: 285496b h: refs/heads/master v: v3
1 parent 749a70a commit 7024808

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
@@ -5,7 +5,7 @@ refs/heads/snap-stage3: eb8fd119c65c67f3b1b8268cc7341c22d39b7b61
55
refs/heads/try: d324a424d8f84b1eb049b12cf34182bda91b0024
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
8-
refs/heads/try2: 757a2afb6b80cb4dbdcb8069f1af511ec42e8670
8+
refs/heads/try2: 285496bd550817094c31167e7e49378a35560842
99
refs/heads/incoming: d9317a174e434d4c99fc1a37fd7dc0d2f5328d37
1010
refs/heads/dist-snap: 22efa39382d41b084fde1719df7ae8ce5697d8c9
1111
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596

branches/try2/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)