Skip to content

Commit 75396b2

Browse files
committed
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.
2 parents 594371b + b8dc103 commit 75396b2

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

src/libcollections/priority_queue.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -529,10 +529,9 @@ impl<'a, T> Iterator<&'a T> for Items<'a, T> {
529529
}
530530

531531
impl<T: Ord> FromIterator<T> for PriorityQueue<T> {
532-
fn from_iter<Iter: Iterator<T>>(iter: Iter) -> PriorityQueue<T> {
533-
let mut q = PriorityQueue::new();
534-
q.extend(iter);
535-
q
532+
fn from_iter<Iter: Iterator<T>>(mut iter: Iter) -> PriorityQueue<T> {
533+
let vec: Vec<T> = iter.collect();
534+
PriorityQueue::from_vec(vec)
536535
}
537536
}
538537

0 commit comments

Comments
 (0)