indexmap-rs / indexmap

A hash table with consistent order and fast iteration; access items by key or sequence index
https://docs.rs/indexmap/
Other
1.67k stars 150 forks source link

Add splicing iterators #294

Closed cuviper closed 8 months ago

cuviper commented 8 months ago

IndexMap::splice and IndexSet::splice will drain the specified range, and then insert items from an iterator to replace that range. This is like Vec::splice, except if any new keys match the retained entries outside the range, then those keep their relative position.

Resolves #274.

cuviper commented 8 months ago

It might be possible to optimize this with some unsafe hacking, but I think this is pretty reasonable for now.