mirror of
https://github.com/rust-lang/rust.git
synced 2026-06-02 15:56:09 +03:00
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:
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user