3 ms·
std::vector doesn't support efficient random deletes, so this (a generalization of std::vector along one specific axis) won't either. Efficient random deletes
by oasisaimlessly 2y ago
std::vector doesn't support efficient random deletes, so this (a generalization of std::vector along one specific axis) won't either.
Efficient random deletes and contiguous hole-free storage are completely at odds with each other.
- sensen7 2y agoThey aren't: https://github.com/GossiperLoturot/densemap https://github.com/GossiperLoturot/densemap
- wffurr 2y agoThat’s a map, not an indexed array, and it’s slower than Vec across the board per its own benchmarks.
- sensen7 2y agoYes, 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.
- oasisaimlessly 2y agoYou can't refer to this collection via a slice (std::span / &[T]), so it's not what I meant when I said "contiguous hole-free storage".