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 more indexed methods to entries #310

Closed cuviper closed 7 months ago

cuviper commented 7 months ago

For IndexedEntry, OccupiedEntry, and RawOccupiedEntryMut, this adds move_index and swap_indices methods that work like the top-level IndexMap methods using the current index of the entry.

For VacantEntry this adds shift_insert, while RawVacantEntryMut adds shift_insert and shift_insert_hashed_nocheck, offering a way to insert at a particular index while shifting other entries as needed.

Finally, for IndexMap and IndexSet this adds shift_insert using OccupiedEntry::move_index or VacantEntry::shift_insert.