Closed serzhiio closed 4 years ago
Sadly I think this will be hard to implement in evmap the way it's currently structured. This is a result of a deeper design choice where a single enum
is used for all of evmap's operations, regardless of the constraints on V
(in this case V: Ord
). There isn't a way in Rust to say "this variant exists only if V: Ord
", so we can't actually add a sort-like method without always requiring V: Ord
.
That said, this may be possible to implement entirely in user code with @novacrazy's #13, though I'm not sure. We'd have to figure out how to let the user modify the vector without giving mutable access to the underlying values. Maybe we could expose an fn sort() where V: Ord
that calls remove and then update somehow?
@jonhoo it would be nice to have ability to process vector items by index and make insertions/deletings.
As i see it now to update vector with few new elements i should .empty()
it first and then .insert()
all elements onw by one including new one. It looks not efficient!
Now that the values are not even necessarily stored in a vector, this is pretty much impossible. We could use a BTreeBag
for the values instead of a HashBag
, and then require that V: Ord
, but that seems like a big change for relatively little gain at the moment.
Guys, is it possible to sort values vector without replacing whole array? I mean just make vector.sort() or like that to save new values order?