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.
This commit is contained in:
bors 2014-08-22 23:55:50 +00:00
commit 75396b2a06
1 changed files with 3 additions and 4 deletions

View File

@ -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)
}
}