-
Notifications
You must be signed in to change notification settings - Fork 13.6k
RFC: Btree query API #27135
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
RFC: Btree query API #27135
Conversation
(rust_highfive has picked a reviewer for you, use r? to override) |
@gankro Wow, this is really cool, but definitely highlights the need for some kind of parametric mutability. |
self.map.max().map(|r| r.0) | ||
} | ||
|
||
/// Gets the closest value to the given key that is less than it. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/key/value/
(Same for the following methods.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All should presumably be element.
I'm just really happy I didn't have to write 12 node search procedures as well. I was dreading the impl until I realized Found/GoDown was basically sufficient. |
}}; | ||
}}, | ||
Internal(internal_handle) => {{ | ||
temp_node = internal_handle.into_{dir}_edge{muta_ext}().into_edge{muta_ext}(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a tidy error on this line.
Bench results:
|
@@ -228,6 +228,665 @@ impl<K: Ord, V> BTreeMap<K, V> { | |||
} | |||
} | |||
|
|||
// Rust's macro system is so attrocious at being generic over mutability |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/attrocious/atrocious/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This correction made my day
RFC closed. |
@apasel422 Note that you might want to steal these bench changes for profiling parent pointer stuff. |
This is an implementation of the core functionality of rust-lang/rfcs#1195 which is not yet accepted (largely due to bikeshedding naming -- but also on what removal/entry APIs to expose).
Note that the vast majority of the code was generated by a program (see comments).
I believe I've exhaustively tested every single code path with my unit test.
Note that removal/entry APIs are not yet provided; I'm of the opinion that a major refactor of the internals to use parent pointers should be done first. Then search/removal/entry/range can basically share the exact same source code with no overhead. It's also expected to be substantially more efficient due to not needing to maintain an explicit search stack for insert/remove/range/entry.