diff options
| author | Huon Wilson <dbau.pp+github@gmail.com> | 2013-12-19 16:53:02 +1100 |
|---|---|---|
| committer | Huon Wilson <dbau.pp+github@gmail.com> | 2013-12-20 12:38:46 +1100 |
| commit | 48fedcb36ffdb4248c238a1bfa7a846e6e27cb68 (patch) | |
| tree | 1c5efc1bd2871cbbb038bf2f2999d5192bf28dd1 /src/libextra/priority_queue.rs | |
| parent | 721609e4ae50142e631e4c9d190a6065fd3f63f7 (diff) | |
| download | rust-48fedcb36ffdb4248c238a1bfa7a846e6e27cb68.tar.gz rust-48fedcb36ffdb4248c238a1bfa7a846e6e27cb68.zip | |
extra: remove sort in favour of the std method.
Fixes #9676.
Diffstat (limited to 'src/libextra/priority_queue.rs')
| -rw-r--r-- | src/libextra/priority_queue.rs | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/src/libextra/priority_queue.rs b/src/libextra/priority_queue.rs index 77d1c5cdcf4..d2cace5e6f4 100644 --- a/src/libextra/priority_queue.rs +++ b/src/libextra/priority_queue.rs @@ -213,7 +213,6 @@ impl<T: Ord> Extendable<T> for PriorityQueue<T> { #[cfg(test)] mod tests { - use sort::merge_sort; use priority_queue::PriorityQueue; #[test] @@ -231,7 +230,8 @@ mod tests { #[test] fn test_top_and_pop() { let data = ~[2u, 4, 6, 2, 1, 8, 10, 3, 5, 7, 0, 9, 1]; - let mut sorted = merge_sort(data, |x, y| x.le(y)); + let mut sorted = data.clone(); + sorted.sort(|x, y| x.le(y)); let mut heap = PriorityQueue::from_vec(data); while !heap.is_empty() { assert_eq!(heap.top(), sorted.last()); @@ -311,11 +311,14 @@ mod tests { assert_eq!(heap.len(), 5); } - fn check_to_vec(data: ~[int]) { + fn check_to_vec(mut data: ~[int]) { let heap = PriorityQueue::from_vec(data.clone()); - assert_eq!(merge_sort(heap.clone().to_vec(), |x, y| x.le(y)), - merge_sort(data, |x, y| x.le(y))); - assert_eq!(heap.to_sorted_vec(), merge_sort(data, |x, y| x.le(y))); + let mut v = heap.clone().to_vec(); + v.sort(|x, y| x.le(y)); + data.sort(|x, y| x.le(y)); + + assert_eq!(v, data); + assert_eq!(heap.to_sorted_vec(), data); } #[test] |
