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
+3 -4
View File
@@ -529,10 +529,9 @@ fn size_hint(&self) -> (uint, Option<uint>) { self.iter.size_hint() }
}
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)
}
}