25 ms·
It seems that indexmap would fit your bill: Repo: https://github.com/bluss/indexmap https://github.com/bluss/indexmap IndexMap type itself: https://docs.rs/in
by paavohtl 4y ago
It seems that indexmap would fit your bill:
Repo: https://github.com/bluss/indexmap https://github.com/bluss/indexmap
IndexMap type itself: https://docs.rs/indexmap/latest/indexmap/map/struct.IndexMap.html https://docs.rs/indexmap/latest/indexmap/map/struct.IndexMap...
It has amortized O(1) reads and writes, and it supports removal without maintaining order in O(1), or while maintaining order in O(n).
- nyanpasu64 4y agoI was not initially aware of O(n) order-preserving shift_remove[...](). Although likely not a problem in practice, removing a large number of items one by one (eg. when a user is deleting a selection containing many file associations) can result in quadratic behavior. I found that you can avoid that by calling retain() (at the cost of being a higher-order function) to keep/remove every item in the list in a single pass (linear time is fast enough for INI files). So in retrospect IndexMap would be a workable choice, if used carefully.