Hacker News new | ask | show | jobs
by wffurr 457 days ago
That’s a map, not an indexed array, and it’s slower than Vec across the board per its own benchmarks.
1 comments

Yes, it's a map that provides efficient random deletes and contiguous hole-free storage, proving that they are not completely at odds with each other.

If you don't care about the map part, you can get the same behavior by just moving the last element in the place of the newly removed element. This invalidates all indices, which is what the DenseMap's overhead is meant to avoid, but Vec's remove also invalidates indices. Vec's remove is strictly worse except that it preserves the ordering if the Vec is sorted.