r/rust•
Noctune

scanmut: multi insert/remove from vec in O(n) time

I just released scanmut for O(n) Vec multi-insert and multi-delete.

The catch is that the inserted/removed indices have to be in monotonically non-increasing order for inserts and monotonically increasing order for removals.

It provides both a simple high-level multi_insert/multi_delete function and lower-level Inserter and Remover types. A benefit of the lower-level types is that they allow you to inspect the slice while you are inserting and removing. multi_delete can basically be seen as a retain, but by index instead of a predicate.

no_std compatible.

It's basically a wrapper around a fair bit of unsafe code, so code reviews are very welcome.

Posted Dec 1, 2019, 1:58 PM UTC · edited

4913
Loading comments…