-
Notifications
You must be signed in to change notification settings - Fork 185
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 ZeroTrie probe function for stepwise iteration. #4725
Conversation
/// | ||
/// assert_eq!(&results, data); | ||
/// ``` | ||
pub fn probe(&mut self, index: usize) -> Option<u8> { |
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.
Thought: We could also return the number of children in order to avoid re-checking the same node an extra time.
/// Probes the next byte in the cursor, stepping the cursor and returning the byte. | ||
/// | ||
/// This function is similar to [`Self::step()`], but it takes an index instead of a char. | ||
/// This enables stepwise iteration over the contents of the trie. |
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.
I don't think I understand what this means
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.
Can you suggest wording that explains it better? This was my attempt at explaining it clearly+succinctly
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.
I can't suggest wording because I don't understand what this means :)
I'm looking at step and still not understanding how these relate. I suspect wording it less dependently on step will help, and you can mention the correlation after that.
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.
I reworded the first paragraph of the doc string. Does that help explain the second paragraph?
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.
If there is only one child node, step
and probe
have the same behavior. If there are multiple children, probe
can walk them by their index, whereas step
binary searches to find the desired child.
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.
yeah this works
probe
is toiter
asstep
is toget
.I created this in order to be more clever in how we canonicalize IANA names for #4031.
Happy to entertain other naming suggestions.