Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign up`BinaryHeap` owned iterators should yield items in heap order #59278
Comments
jonhoo
referenced this issue
Mar 18, 2019
Open
Add retain() and drain() for BTreeMap, BTreeSet, BinaryHeap #42849
estebank
added
the
T-libs
label
Mar 18, 2019
This comment has been minimized.
This comment has been minimized.
|
Isn't |
This comment has been minimized.
This comment has been minimized.
|
@clarfon No, because getting the largest |
This comment has been minimized.
This comment has been minimized.
ckaran
commented
Apr 2, 2019
|
@clarfon In addition to what @scottmcm said, |
This comment has been minimized.
This comment has been minimized.
|
@ckaran |
jonhoo commentedMar 18, 2019
Currently, both
BinaryHeap::into_iterandBinaryHeap::drainyield the heap elements in an arbitrary order. This seems counter-intuitive given the nature of a heap. Sadly, we can't simply change their behavior behind the scenes, as we would have to remove the implementation ofDoubleEndedIterator. Should we perhaps addinto_ordered_iteranddrain_ordered? The implementation is pretty straightforward so I'd be happy to submit a PR.