Skip to content

Commit 0edcaeb

Browse files
thestingerbrson
authored andcommitted
---
yaml --- r: 36767 b: refs/heads/try2 c: 7bd0d71 h: refs/heads/master i: 36765: a0c21f0 36763: 749a70a 36759: 652ad5c 36751: ba3bab5 36735: 92d5526 v: v3
1 parent 8748678 commit 0edcaeb

File tree

2 files changed

+13
-12
lines changed

2 files changed

+13
-12
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: e00c3b05e110ab4b3cf6d60e29c59fad2b5921d6
8+
refs/heads/try2: 7bd0d7155495486b35c67772eb96c930af2cf7d0
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: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@ pub struct PriorityQueue <T: Copy Ord>{
88

99
impl <T: Copy Ord> PriorityQueue<T> {
1010
/// Returns the greatest item in the queue - fails if empty
11-
pure fn top(&self) -> T { self.data[0] }
11+
pure fn top(&self) -> &self/T { &self.data[0] }
1212

1313
/// Returns the greatest item in the queue - None if empty
14-
pure fn maybe_top(&self) -> Option<T> {
14+
pure fn maybe_top(&self) -> Option<&self/T> {
1515
if self.is_empty() { None } else { Some(self.top()) }
1616
}
1717

@@ -151,7 +151,7 @@ mod tests {
151151
let mut sorted = merge_sort(data, le);
152152
let mut heap = from_vec(data);
153153
while heap.is_not_empty() {
154-
assert heap.top() == sorted.last();
154+
assert *heap.top() == sorted.last();
155155
assert heap.pop() == sorted.pop();
156156
}
157157
}
@@ -160,22 +160,22 @@ mod tests {
160160
fn test_push() {
161161
let mut heap = from_vec(~[2, 4, 9]);
162162
assert heap.len() == 3;
163-
assert heap.top() == 9;
163+
assert *heap.top() == 9;
164164
heap.push(11);
165165
assert heap.len() == 4;
166-
assert heap.top() == 11;
166+
assert *heap.top() == 11;
167167
heap.push(5);
168168
assert heap.len() == 5;
169-
assert heap.top() == 11;
169+
assert *heap.top() == 11;
170170
heap.push(27);
171171
assert heap.len() == 6;
172-
assert heap.top() == 27;
172+
assert *heap.top() == 27;
173173
heap.push(3);
174174
assert heap.len() == 7;
175-
assert heap.top() == 27;
175+
assert *heap.top() == 27;
176176
heap.push(103);
177177
assert heap.len() == 8;
178-
assert heap.top() == 103;
178+
assert *heap.top() == 103;
179179
}
180180

181181
#[test]
@@ -241,11 +241,12 @@ mod tests {
241241

242242
#[test]
243243
#[should_fail]
244-
fn test_empty_top() { from_vec::<int>(~[]).top(); }
244+
fn test_empty_top() { let empty = from_vec::<int>(~[]); empty.top(); }
245245

246246
#[test]
247247
fn test_empty_maybe_top() {
248-
assert from_vec::<int>(~[]).maybe_top().is_none();
248+
let empty = from_vec::<int>(~[]);
249+
assert empty.maybe_top().is_none();
249250
}
250251

251252
#[test]

0 commit comments

Comments
 (0)