-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Document iteration order of retain
functions
#86790
Conversation
For `HashSet` and `HashMap`, this simply copies the comment from `BinaryHeap::retain`. For `BTreeSet` and `BTreeMap`, this adds an additional guarantee that wasn't previously documented. I think that because these data structures are inherently ordered and other functions guarantee ordered iteration, it makes sense to provide this guarantee for `retain` as well.
@rustbot label: +S-waiting-on-review |
Are there any theoretical optimizations that would be precluded by guaranteeing a specific order? |
BTree could visit in pre- or post-order, but I don't know if that would have any real advantages. |
Maybe someone more familiar with B-trees could comment on this, but for arbitrary closures I don't believe |
This promises .retain() on BTreeMap and BTreeSet visits the elements in order, as they already do right now. My thoughts: I can imagine there might be some more efficient implementation that calls the predicate in a different order based on the structure of the tree, but there are probably already people depending on the order of .retain(), since we have the same promise for some other data structures. If we find out about an optimized version that does not call the predicate in order, we can consider adding a @rfcbot merge |
Team member @m-ou-se has proposed to merge this. The next step is review by the rest of the tagged team members: No concerns currently listed. Once a majority of reviewers approve (and at most 2 approvals are outstanding), this will enter its final comment period. If you spot a major issue that hasn't been raised at any point in this process, please speak up! See this document for info about what commands tagged team members can give me. |
🔔 This is now entering its final comment period, as per the review above. 🔔 |
The final comment period, with a disposition to merge, as per the review above, is now complete. As the automated representative of the governance process, I would like to thank the author for their work and everyone else who contributed. The RFC will be merged soon. |
why is this still open 🙃 @bors r=m-ou-se rollup |
📌 Commit 2dd69aa has been approved by |
Rollup of 14 pull requests Successful merges: - rust-lang#86410 (VecMap::get_value_matching should return just one element) - rust-lang#86790 (Document iteration order of `retain` functions) - rust-lang#87171 (Remove Option from BufWriter) - rust-lang#87175 (Stabilize `into_parts()` and `into_error()`) - rust-lang#87185 (Fix panics on Windows when the build was cancelled) - rust-lang#87191 (Package LLVM libs for the target rather than the build host) - rust-lang#87255 (better support for running libcore tests with Miri) - rust-lang#87266 (Add testcase for 87076) - rust-lang#87283 (Add `--codegen-backends=foo,bar` configure flag) - rust-lang#87322 (fix: clarify suggestion that `&T` must refer to `T: Sync` for `&T: Send`) - rust-lang#87358 (Fix `--dry-run` when download-ci-llvm is set) - rust-lang#87380 (Don't default to `submodules = true` unless the rust repo has a .git directory) - rust-lang#87398 (Add test for fonts used for module items) - rust-lang#87412 (Add missing article) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
@rustbot label -to-announce |
For
HashSet
andHashMap
, this simply copies the comment fromBinaryHeap::retain
.For
BTreeSet
andBTreeMap
, this adds an additional guarantee thatwasn't previously documented. I think that because these data structures
are inherently ordered and other functions guarantee ordered iteration,
it makes sense to provide this guarantee for
retain
as well.