diff options
| author | bors <bors@rust-lang.org> | 2014-08-22 23:55:50 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2014-08-22 23:55:50 +0000 |
| commit | 75396b2a06a9372ed4ddcc3e5bcf56d18f1973ae (patch) | |
| tree | 70c57ba683061074942ba64c8f3ef823d9475bfc | |
| parent | 594371bb6770e70b8c1ee12768bf1c2f6969e3b3 (diff) | |
| parent | b8dc103a950d1dec441e1936b2d7b18457571e1b (diff) | |
| download | rust-75396b2a06a9372ed4ddcc3e5bcf56d18f1973ae.tar.gz rust-75396b2a06a9372ed4ddcc3e5bcf56d18f1973ae.zip | |
auto merge of #16663 : Gankro/rust/heapify, r=alexcrichton
Heapify is O(n), extend as currently implemented is O(nlogn). No brainer. Currently investigating whether extend can just be implemented as a local heapify.
| -rw-r--r-- | src/libcollections/priority_queue.rs | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/src/libcollections/priority_queue.rs b/src/libcollections/priority_queue.rs index eedb61c0712..674fa129943 100644 --- a/src/libcollections/priority_queue.rs +++ b/src/libcollections/priority_queue.rs @@ -529,10 +529,9 @@ impl<'a, T> Iterator<&'a T> for Items<'a, T> { } impl<T: Ord> FromIterator<T> for PriorityQueue<T> { - fn from_iter<Iter: Iterator<T>>(iter: Iter) -> PriorityQueue<T> { - let mut q = PriorityQueue::new(); - q.extend(iter); - q + fn from_iter<Iter: Iterator<T>>(mut iter: Iter) -> PriorityQueue<T> { + let vec: Vec<T> = iter.collect(); + PriorityQueue::from_vec(vec) } } |
