Repository navigation
Implement split_off for BTreeMap and BTreeSet (RFC 509) - #33947
Conversation
|
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @gankro (or someone else) soon. If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes. Please see the contribution instructions for more information. |
|
|
||
| // Source and destination must have the same height. | ||
| unsafe fn move_edges<K, V>( | ||
| source: Option<*mut BoxedNode<K, V>>, source_offset: usize, |
There was a problem hiding this comment.
I think I'd prefer if this function took pointers not wrapped in Option - it makes more sense intuitively to me that you would check if you have edges to move, and if so, you call move_edges. I could be convinced otherwise though.
There was a problem hiding this comment.
In fact, it might be even nicer to just take a NodeRef - it is easy to figure out where to place the edges.
|
Oh no. This is bad commit. |
|
@gereeter, fixed |
There was a problem hiding this comment.
This might be slightly nicer as a match on (split_edge.force(), right_node.force()).
|
Sans nits, this looks good to me. Thank you, @xosmig! |
|
r? @aturon |
|
@gereeter, Thanks for review! |
|
should I squash it all into one commit? |
|
@bors: delegate=gereeter |
|
✌️ @gereeter can now approve this pull request |
|
Yes, I think that squashed PRs are standard practice, at least for collections changes like this that don't really have separate, logical steps. |
|
The Travis failure looks completely unrelated to this PR. @bors r+ |
|
📌 Commit e3adad6 has been approved by |
Fixes #19986 and refactors common with append methods.
It splits the tree with O(log n) operations and then calculates sizes by traversing the lower one.
CC @gereeter