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.71k stars 150 forks source link

Re-deprecate `remove`, `remove_entry`, and `take` #293

Closed cuviper closed 9 months ago

cuviper commented 9 months ago

It's a frequent point of confusion that these methods disrupt the order (by swapping the last item), but that choice was made for performance. The alternative shift_* removals are also disruptive to indices, and require O(n) updates instead of O(1).

The deprecation notes recommend instead choosing a swap/shift method explicitly. This doesn't mean that we'll ever actually remove these deprecated methods, since they are still nice to have when acting as a drop-in HashMap replacement, but the warning will hopefully help avoid surprises.

Resolves #241. Resolves #220.