-
Notifications
You must be signed in to change notification settings - Fork 12.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add drain_filter for BinaryHeap #42849
Comments
Sounds good to me. I agree that this part of the API would be good to keep consistent between HashMap/HashSet and BTreeMap/BTreeSet. Please submit a PR. |
This comment was marked as spam.
This comment was marked as spam.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
If someone ever gets around to this, it would be a shame to repeat the mistake of passing |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Getting nowhere so far, so I'll pass this to future volunteers. |
Ah sure, it's about iterating in a specific order, not removing (was confused with |
I mean, it's a heap... If I want to re-use the heap, it seems pretty reasonable to use |
Is it acceptable to implement this using brute force and then redo it later for performance gains? Just do something like:
|
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
It turns out that a
So I think it's only worth the trouble if it operates on a range. Secondly, I wondered why |
This comment has been minimized.
This comment has been minimized.
…manieu Add BinaryHeap::retain as suggested in rust-lang#42849 This PR implements retain for BinaryHeap as suggested in rust-lang#42849. This is my first PR for Rust, so please let me know if I should be doing anything differently, thanks!
…manieu Add BinaryHeap::retain as suggested in rust-lang#42849 This PR implements retain for BinaryHeap as suggested in rust-lang#42849. This is my first PR for Rust, so please let me know if I should be doing anything differently, thanks!
Rollup of 8 pull requests Successful merges: - rust-lang#69456 (fix misleading type annotation diagonstics) - rust-lang#71330 (Only run dataflow for const qualification if type-based check would fail) - rust-lang#71480 (Improve PanicInfo examples readability) - rust-lang#71485 (Add BinaryHeap::retain as suggested in rust-lang#42849) - rust-lang#71512 (Remove useless "" args) - rust-lang#71527 (Miscellaneous cleanup in `check_consts`) - rust-lang#71534 (Avoid unused Option::map results) - rust-lang#71535 (Fix typos in docs for keyword "in") Failed merges: r? @ghost
All but two of the methods originally requested here have since been implemented. I'm splitting this issue so that we have one ticket for per method. This ticket is for BinaryHeap::drain_filter. BTreeMap/BTreeSet::drain_filter are tracked at #70530. BinaryHeap::retain is tracked at #71503. BTreeMap/BTreeSet::retain are part of rust-lang/rfcs#1338. |
Should |
@rustbot claim |
@rustbot claim |
Some questions from implementing this feature:
|
std::collections::BinaryHeap
is missing adrain_filter
method (rust-lang/rfcs#2140).The text was updated successfully, but these errors were encountered: