Closed dhouck closed 8 months ago
I think you cannot have the feature that you need and at the same time an efficient function to change the priority of an item (how would you identify it in case of duplicates?).
If you don't ever need to retrieve the (item, priority) tuple by item, then you can probably use the BinaryHeap
instead, that is more efficient (both in time and space) than the data structures implemented by this trait for that use case, as also shown in the benchmarks
I know I considered it and rejected it for some reason, but I donʼt remember what. But that does look like it should work for at least most use cases.
Sometimes you want map values which are unhashable/incomparable, and sometimes you want to allow duplicates. For a project I was working on (since refactored), I would need to change the values in a way that altered there hashes.
All of this can be made to work with a
struct
likewhere the implementation ensures that
nonce
is always unique (a simple counter would do along with a manual implementation ofClone
) and onlynonce
participates in hashing and equality (which is why I donʼtderive
Hash
,PartialEq
, or evenEq
(because the derivable one requiresT: Eq
even though this isnʼt needed)); they can be implemented manually or with thederivative
crate).The harder part is making an ergonomic UI to handle this, and I donʼt have enough of a handle on ergonomic Rust to design one at the moment (which is why this is an issue not a PR).