Skip to content
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

cordyceps: List::insert_sorted #187

Open
hawkw opened this issue Jun 3, 2022 · 2 comments
Open

cordyceps: List::insert_sorted #187

hawkw opened this issue Jun 3, 2022 · 2 comments
Labels
crate/cordyceps Related to the `cordyceps` crate kind/enhancement New feature or request

Comments

@hawkw
Copy link
Owner

hawkw commented Jun 3, 2022

it would be nice to have a way to use cordyceps List to build a sorted structure based on a T: Ord key, perhaps using the cursor API. this would allow using List as a kind of bad (O(n)) version of a priority queue.

of course, this would require only using insert_sorted to add to the list, as it would require that the list is always kept in a sorted state. perhaps the best approach would be a wrapper type around a List that disallows the push_front API...

@hawkw hawkw added the kind/enhancement New feature or request label Jun 3, 2022
@hawkw
Copy link
Owner Author

hawkw commented Jun 3, 2022

cc @jamesmunns

@jamesmunns
Copy link
Collaborator

As prior art, heapless also has a sorted_linked_list module/structure: https://docs.rs/heapless/latest/heapless/sorted_linked_list/index.html.

I agree making this a separate type (rather than another method on the existing list) is a good idea for correctness.

@hawkw hawkw added the crate/cordyceps Related to the `cordyceps` crate label Jul 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
crate/cordyceps Related to the `cordyceps` crate kind/enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants