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:
commit
75396b2a06
@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user