-
Notifications
You must be signed in to change notification settings - Fork 13.3k
DList update #7944
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
DList update #7944
Conversation
This impl was missing for unknown reason.
Make the core Deque implementation a bit simpler by using Option methods when we simply map on a Some value, and deduplicate some common lines.
Factor out internal methods for pop/push ~Node<T>, This allows moving nodes instead of destructuring and allocating new. Make use of this in .merge() so that it requires no allocations when merging two DList.
Add methods to move back element to front or front element to back, without reallocating nodes.
These tests for ~[] performance don't really belong here, they were for comparison.
We don't need TotalOrd for ordered insertion, just the normal sort order Ord.
.peek_next() needs to check the element counter just like the .next() and .next_back() iterators do. Also clarify .insert_next() doc w.r.t double ended iteration.
The commit |
Otherwise looks good, feel free to r=bblum once you decide how to address my above comment. |
I didn't realize DList had turned into an owned data structure with raw back pointers in the time since I wrote it. It's good to see. |
I appreciate the comment on naming. At the moment nodes are not exposed at all, so methods taking nodes are not possible. |
Factor out internal methods to pop/push list nodes so that .merge() and .rotate_to_front(), .rotate_to_back() (new methods) can be implemented without allocating nodes. With that, some cleanup changes to DList use of Option, and adding a missing Encodable implementation.
…=giraffate Add MSRV to deprecated_cfg_attr changelog: Add MSRV to [`deprecated_cfg_attr`] closes: rust-lang#7922
Factor out internal methods to pop/push list nodes so that .merge() and .rotate_to_front(), .rotate_to_back() (new methods) can be implemented without allocating nodes.
With that, some cleanup changes to DList use of Option, and adding a missing Encodable implementation.