-
Notifications
You must be signed in to change notification settings - Fork 0
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
Question: Isn't this possible without a full code-port? #19
Comments
The problem with newtyping the contained values so that they each hold runtime state required for ordering is that such state must be duplicated across every element in the collection. This has both time and space costs that can be avoided if that state is stored only once per collection. |
If I understand correctly, could you not then get around large |
Sure, but that still stores an additional pointer per element and suffers the cost of indirection to reach the ordering (in addition to the cost of the Rc's, or Arc's if multithreaded, alloc + refcounting). |
Also, your The outer wrapper type would furthermore have to do translation to/from the stored newtyped keys, which also adds further cost. |
That makes sense. For sure it would be a sub-optimal solution. |
Hi there, cool work!
I found this crate from your stack overflow comment here while looking for more flexible ways of imposing custom orderings inside
BTreeMaps
. I need such flexibility for therange_bounds_map
crate I maintain. Specifically ripytide/nodit#21My Question:
Is this not already possible without a full code-port by simply wrapping the
BTreeMap
in a new struct and then translating the types you get given into a newtype struct that dynamically applies the specifiedTotalOrder
?Something like:
Apologies if I have misunderstood something.
The text was updated successfully, but these errors were encountered: